Skip to content

Instantly share code, notes, and snippets.

@andrewpthorp
Created December 6, 2013 16:49
Show Gist options
  • Save andrewpthorp/7828107 to your computer and use it in GitHub Desktop.
Save andrewpthorp/7828107 to your computer and use it in GitHub Desktop.
Sample Dynamic Emails in Stripe Checkout.
<html>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://checkout.stripe.com/checkout.js"></script>
<input type="email" class="email-field" />
<button id="customButton">Purchase</button>
<script>
var handler = StripeCheckout.configure({
key: '<YOUR PUBLIC API KEY>',
token: function(token, args) {
// Use the token to create the charge with a server-side script.
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Site Name',
description: 'Product Description',
amount: 2000, // Product Amount
email: $('.email-field').val()
});
e.preventDefault();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment