Skip to content

Commit

Permalink
fix(payment): CHECKOUT-4852 Check for status code instead as quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchin committed May 4, 2020
1 parent ff199b6 commit 1666289
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/payment/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,18 @@ class Payment extends Component<PaymentProps & WithCheckoutPaymentProps & WithLa
}

if (isRequestError(error)) {
const { body, headers } = error;
const { body, headers, status } = error;

if (body.type === 'provider_error' && headers.location) {
window.top.location.assign(headers.location);
}

// Reload the checkout object to get the latest `shouldExecuteSpamCheck` value,
// which will in turn make `SpamProtectionField` visible again.
if (body.type === 'spam_protection_expired' || body.type === 'spam_protection_failed') {
// NOTE: As a temporary fix, we're checking the status code instead of the error
// type because of an issue with Nginx config, which causes the server to return
// HTML page instead of JSON response when there is a 429 error.
if (status === 429 || body.type === 'spam_protection_expired' || body.type === 'spam_protection_failed') {
this.setState({ didExceedSpamLimit: true });

await loadCheckout();
Expand Down

0 comments on commit 1666289

Please sign in to comment.