Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sebastiancrossa opened this issue Dec 16, 2019 · 0 comments
Open

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

sebastiancrossa opened this issue Dec 16, 2019 · 0 comments

Comments

@sebastiancrossa
Copy link

sebastiancrossa commented Dec 16, 2019

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"
          />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant