Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

WooPayments::has_sandbox_account │ private │ WC 1.0

Determines if the current account is a sandbox account.

Sandbox accounts are accounts that were onboarded in test mode. They are different from test accounts (i.e. test-drive accounts).

Sandbox accounts are generally created in development or staging environments when simulating live onboarding.

Метод класса: WooPayments{}

Хуков нет.

Возвращает

bool. True if the account is a sandbox account, false otherwise.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->has_sandbox_account(): bool;

Код WooPayments::has_sandbox_account() WC 11.2.1

private function has_sandbox_account(): bool {
	if ( $this->proxy->call_function( 'function_exists', 'wcpay_get_container' ) &&
		$this->proxy->call_function( 'class_exists', 'WC_Payments_Account' ) ) {

		$woopayments_container = $this->proxy->call_function( 'wcpay_get_container' );
		$account_service       = $woopayments_container->get( 'WC_Payments_Account' );
		if ( ! empty( $account_service ) &&
			$this->proxy->call_function( 'method_exists', $account_service, 'get_account_status_data' ) &&
			$this->proxy->call_function( 'is_callable', array( $account_service, 'get_account_status_data' ) ) ) {

			$account_status = $account_service->get_account_status_data();

			return empty( $account_status['isLive'] ) && empty( $account_status['testDrive'] );
		}
	}

	return false;
}