Skip to content

Keep getting a CORS error when the checkout pop up opens #146

@sebastiancrossa

Description

@sebastiancrossa

Whenever I click on the button that triggers and opens the pop up where the credit card details are entered, I get this CORS error:

Screen Shot 2019-12-16 at 3 44 04 PM

I don't know if it's specific to Stripe, but I get seem to find a workaround.

This is my implementation of the code:

const handleToken = async () => {
    const response = await axios({
      method: 'post',
      url:
        'https://cors-anywhere.herokuapp.com/https://accessmexico.herokuapp.com/charge',
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Credentials': 'true'
      }
    });

    const { status } = response.data;
    console.log('Response:', response.data);

    if (status === 'success') {
      toast('Success!', { type: 'success' });
    } else {
      toast('Something went wrong', { type: 'error' });
    }
  };
<StripeCheckout
            token={() => handleToken()}
            stripeKey="pk_test_[key]"
            amount={parseInt(cleanMonto) * 100}
            name="Reservacion Access"
            locale="auto"
            currency="MXN"
            label="Reservar"
          />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions