Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zmaglica committed Feb 8, 2024
1 parent 2ebe9d1 commit ffb36ec
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions includes/class-wc-payments-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,18 @@ public static function get_filtered_error_message( Exception $e ) {
* @return int
*/
public static function get_filtered_error_status_code( Exception $e ) : int {
$status_code = 400;
$status_code = null;
if ( $e instanceof API_Exception ) {
$status_code = $e->get_http_code() ?? 400;
// Sometimes hosting companies hijack this status code and return their own predefined error page.
// In this case, we want to return a 400 instead, since it will break the flow of the checkout page.
if ( 402 === $status_code ) {
$status_code = 400;
}
$status_code = $e->get_http_code();
}

// Sometimes hosting companies hijack the 402 status code to return their own predefined error page.
// In this case, we want to return a 400 instead, since it will break the flow of the checkout page.
if ( 402 === $status_code ) {
$status_code = 400;
}
return $status_code;

return $status_code ?? 400;
}

/**
Expand Down

0 comments on commit ffb36ec

Please sign in to comment.