[Vuejs]-Using generated Stripe checkout button

0👍

  1. For the first error where Stripe is undefined. That is likely because the Stripe.js library isn’t loaded before that code runs. You’ll need to ensure that you’ve included Stripe.js [1] with this tag in your HTML before any of your JavaScript using Stripe is executed. Note that it’s not loaded async.

<script src="https://js.stripe.com/v3/"></script>

  1. The second error is because when you’re attempting to getElementById the ID that you’re passing is not the same as the ID in the HTML for the button.

The button’s ID is checkout-button-MY_PLAN and the ID you’re trying to find the button with by passing is MY_PLAN. I would recommend updating your call to getElementById to:

let checkoutButton = document.getElementById('checkout-button-MY_PLAN');

[1] https://stripe.com/docs/js/including

Leave a comment