Skip to content

Instantly share code, notes, and snippets.


davewardle/basic-stripe-example.js Secret

Last active Dec 23, 2016
What would you like to do?
Basic Stripe Checkout example
var $form = $('#form');
var handler = StripeCheckout.configure({
key: stripeKey, // make sure to set this, it will look something like pk_test_6pRNASCoBOKtIshFeQd4XMUh
locale: 'auto',
token: function(token) {
// set the token ID in a form input
$form.find( '.sc_stripeToken' ).val( );
// along with the email (optional)
$form.find( '.sc_stripeEmail' ).val( );
// Unbind original form submit trigger before calling again to "reset" it and submit normally.
$form.unbind( 'submit' );
$form.on('submit', function(e) {
// you may want to do some basic validation here
// but remember to validate the data in your PHP later..
var name = 'Example';
var desc = 'Checkout';
var total = 2000; // price in pence!
// you will want to set these variables using the actual form data
// Open Checkout with further options:{
name: name,
description: desc,
zipCode: true,
currency: 'gbp',
amount: total,
billingAddress: true,
allowRememberMe: false,
panelLabel: 'Pay {{amount}}'
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.