Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
Mastercard::is_account_connected
Check if the payment gateway has a payments processor account connected.
Method of the class: Mastercard{}
No Hooks.
Returns
bool. True if the payment gateway account is connected, false otherwise. If the payment gateway does not provide the information, it will return true.
Usage
$Mastercard = new Mastercard(); $Mastercard->is_account_connected( $payment_gateway ): bool;
- $payment_gateway(WC_Payment_Gateway) (required)
- The payment gateway object.
Mastercard::is_account_connected() Mastercard::is account connected code WC 11.1.2
public function is_account_connected( WC_Payment_Gateway $payment_gateway ): bool {
try {
$sandbox_mode = $this->is_mastercard_in_sandbox_mode( $payment_gateway );
// Let null results bubble up to the parent class.
if ( null !== $sandbox_mode ) {
// The gateway keeps a separate credential pair per environment.
$merchant_id_key = $sandbox_mode ? 'test_merchant_id' : 'merchant_id';
$password_key = $sandbox_mode ? 'test_password' : 'password';
return '' !== $this->get_string_option( $payment_gateway, $merchant_id_key )
&& '' !== $this->get_string_option( $payment_gateway, $password_key );
}
} catch ( Throwable $e ) {
// Do nothing but log so we can investigate.
SafeGlobalFunctionProxy::wc_get_logger()->debug(
'Failed to determine if gateway has an account connected: ' . $e->getMessage(),
array(
'gateway' => $payment_gateway->id,
'source' => 'settings-payments',
'exception' => $e,
)
);
}
return parent::is_account_connected( $payment_gateway );
}