Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

WooPayments::has_test_accountprivateWC 1.0

Determines if the current account is a test account.

Test accounts are test-drive accounts. They are different from sandbox accounts (i.e. accounts onboarded in test mode).

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

Хуков нет.

Возвращает

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

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

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

Код WooPayments::has_test_account() WC 11.1.0

private function has_test_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['testDrive'] );
		}
	}

	return false;
}