Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsService::is_test_account_init_error_non_recoverable
Determine if a test account initialization error is non-recoverable for the merchant.
The WooPayments extension surfaces the underlying error details in the REST error response body, which Utils::rest_endpoint_post_request() stores as the WP_Error data.
Method of the class: WooPaymentsService{}
Hooks from the method
Returns
bool. Whether the error is non-recoverable.
Usage
// private - for code of main (parent) class only $result = $this->is_test_account_init_error_non_recoverable( $error ): bool;
- $error(WP_Error) (required)
- The error returned by the test account initialization request.
WooPaymentsService::is_test_account_init_error_non_recoverable() WooPaymentsService::is test account init error non recoverable code WC 11.1.1
private function is_test_account_init_error_non_recoverable( WP_Error $error ): bool {
$error_data = $error->get_error_data();
if ( ! is_array( $error_data ) ) {
return false;
}
$error_type = $error_data['data']['error_type'] ?? $error_data['error_type'] ?? null;
$error_code = $error_data['data']['error_code'] ?? $error_data['error_code'] ?? null;
/**
* Filters the error identifiers for which retrying the WooPayments test account
* initialization cannot succeed.
*
* Each identifier is matched against both the error type and the error code reported
* by the WooPayments extension. When an initialization error matches, the test account
* onboarding step is skipped forward instead of being marked as failed.
*
* @param string[] $identifiers The non-recoverable error identifiers.
* @param WP_Error $error The error returned by the test account initialization request.
*
* @since 11.1.0
*/
$non_recoverable_identifiers = (array) apply_filters(
'woocommerce_woopayments_onboarding_test_account_non_recoverable_errors',
self::ONBOARDING_TEST_ACCOUNT_NON_RECOVERABLE_ERROR_IDENTIFIERS,
$error
);
return in_array( $error_type, $non_recoverable_identifiers, true ) ||
in_array( $error_code, $non_recoverable_identifiers, true );
}