WC_Gateway_Paypal_Notices::manage_account_restriction_flag_for_notice
Handle PayPal order response to manage account restriction notices.
Method of the class: WC_Gateway_Paypal_Notices{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Gateway_Paypal_Notices::manage_account_restriction_flag_for_notice( $http_code, $response_data, $order ): void;
- $http_code(int|string) (required)
- The HTTP status code from the PayPal API response.
- $response_data(array) (required)
- The decoded response data from the PayPal API.
- $order(WC_Order) (required)
- The WooCommerce order object.
Changelog
| Since 10.4.0 | Introduced. |
WC_Gateway_Paypal_Notices::manage_account_restriction_flag_for_notice() WC Gateway Paypal Notices::manage account restriction flag for notice code WC 10.4.3
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();
}
}
}