Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
KlarnaCheckout::is_account_connected
Check if the payment gateway has a payments processor account connected.
Method of the class: KlarnaCheckout{}
No Hooks.
Returns
true|false. True if the payment gateway account is connected, false otherwise. If the payment gateway does not provide the information, it will return true.
Usage
$KlarnaCheckout = new KlarnaCheckout(); $KlarnaCheckout->is_account_connected( $payment_gateway ): bool;
- $payment_gateway(WC_Payment_Gateway) (required)
- The payment gateway object.
KlarnaCheckout::is_account_connected() KlarnaCheckout::is account connected code WC 10.8.1
public function is_account_connected( WC_Payment_Gateway $payment_gateway ): bool {
try {
// Note: Since the credentials used are tied to the WooCommerce store location country (US and non-US),
// the account can become disconnected if the store location changes.
if ( function_exists( 'KCO_WC' ) ) {
$credentials = \KCO_WC()->credentials;
if ( is_object( $credentials ) && is_callable( array( $credentials, 'get_credentials_from_session' ) ) ) {
return ! empty( $credentials->get_credentials_from_session() );
}
}
} 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 );
}