Automattic\WooCommerce\Gateways\PayPal
Notices::manage_account_restriction_flag_for_notice
Handle PayPal order response to manage account restriction notices.
Метод класса: Notices{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = Notices::manage_account_restriction_flag_for_notice( $http_code, $response_data, $order ): void;
- $http_code(int|строка) (обязательный)
- The HTTP status code from the PayPal API response.
- $response_data(массив) (обязательный)
- The decoded response data from the PayPal API.
- $order(WC_Order) (обязательный)
- The WooCommerce order object.
Список изменений
| С версии 10.5.0 | Введена. |
Код Notices::manage_account_restriction_flag_for_notice() Notices::manage account restriction flag for notice WC 11.0.1
public static function manage_account_restriction_flag_for_notice( $http_code, array $response_data, WC_Order $order ): void {
// Clear the restriction flag on successful responses.
if ( in_array( (int) $http_code, array( 200, 201 ), true ) ) {
self::clear_account_restriction_flag();
return;
}
if ( empty( $response_data ) ) {
return;
}
// Set the restriction flag for account-related errors.
if ( 422 === (int) $http_code ) {
$issue = isset( $response_data['details'][0]['issue'] ) ? $response_data['details'][0]['issue'] : '';
if ( in_array( $issue, self::PAYPAL_ACCOUNT_RESTRICTION_ISSUES, true ) ) {
\WC_Gateway_Paypal::log( 'PayPal account restriction flag set due to issues when handling the order: ' . $order->get_id() );
self::set_account_restriction_flag();
}
}
}