Implementing Stripe on Web: Uncaught ReferenceError: StripeCheckout is not defined

StripeCheckout is built on top of Stripe. You need to include the js file that defines StripeCheckout.

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

See the documentation here: https://stripe.com/docs/checkout#integration-custom


The publishable key line should only be executed once the checkout.js file has been downloaded and your javascript file is compiled, for my project this works

<script type="text/javascript" src="https://js.stripe.com/v2/">

$(function(){

  Stripe.setPublishableKey('<%= Rails.configuration.stripe[:PUBLISHABLE_KEY] %>');

});

</script>

To test this open a console using developer tools in your browser and after the page has loaded, paste $('#payment-form') if the console returns a reference to the form in your page then its working.

I have put this in the form page in my app and it solved this error, when it was included in my javascript file even wrapped in the on ready event it caused the same error as you experienced