Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
PaymentGateway::is_onboarding_supported
Check if the payment gateway supports the current store state for onboarding.
Most of the time the current business location should be the main factor, but could also consider other store settings like currency.
Method of the class: PaymentGateway{}
No Hooks.
Returns
true|false|null. True if the payment gateway supports onboarding, false otherwise. If the payment gateway does not provide the information, we will return null to indicate that we don't know.
Usage
$PaymentGateway = new PaymentGateway(); $PaymentGateway->is_onboarding_supported( $payment_gateway, $country_code ): ?bool;
- $payment_gateway(WC_Payment_Gateway) (required)
- The payment gateway object.
- $country_code(string)
- The country code for which to check. This should be an ISO 3166-1 alpha-2 country code.
Default:''
PaymentGateway::is_onboarding_supported() PaymentGateway::is onboarding supported code WC 10.4.3
public function is_onboarding_supported( WC_Payment_Gateway $payment_gateway, string $country_code = '' ): ?bool {
try {
if ( method_exists( $payment_gateway, 'is_onboarding_supported' ) &&
is_callable( array( $payment_gateway, 'is_onboarding_supported' ) ) ) {
// Call with positional argument; normalize to bool|null.
$result = call_user_func( array( $payment_gateway, 'is_onboarding_supported' ), $country_code );
// Preserve null to indicate "unknown" state.
if ( is_null( $result ) ) {
return null;
}
if ( is_bool( $result ) ) {
return $result;
}
return filter_var( $result, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
}
} catch ( Throwable $e ) {
// Do nothing but log so we can investigate.
SafeGlobalFunctionProxy::wc_get_logger()->debug(
'Failed to determine if gateway supports onboarding: ' . $e->getMessage(),
array(
'gateway' => $payment_gateway->id,
'country' => $country_code,
'source' => 'settings-payments',
'exception' => $e,
)
);
}
// If we reach here, just assume that we don't know if the gateway supports onboarding.
return null;
}