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.
Метод класса: PaymentGateway{}
Хуков нет.
Возвращает
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.
Использование
$PaymentGateway = new PaymentGateway(); $PaymentGateway->is_onboarding_supported( $payment_gateway, $country_code ): ?bool;
- $payment_gateway(WC_Payment_Gateway) (обязательный)
- The payment gateway object.
- $country_code(строка)
- The country code for which to check. This should be an ISO 3166-1 alpha-2 country code.
По умолчанию:''
Код PaymentGateway::is_onboarding_supported() PaymentGateway::is onboarding supported WC 10.5.0
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;
}