Skip to content

Instantly share code, notes, and snippets.

@andrewpthorp
Created January 9, 2014 22:04
Show Gist options
  • Save andrewpthorp/8342935 to your computer and use it in GitHub Desktop.
Save andrewpthorp/8342935 to your computer and use it in GitHub Desktop.
Custom Checkout
<html>
<body>
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton">Purchase</button>
<form action="charge.php" method="POST">
<input type="hidden" name="stripeToken" class="token" />
<input type="hidden" name="stripeEmail" class="email" />
</form>
<script>
var handler = StripeCheckout.configure({
key: 'your_public_key',
token: function(token, args) {
$('input.token').val(token.id);
$('input.email').val(token.email);
$('form').submit();
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Name',
description: 'Description',
amount: 1000
});
e.preventDefault();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment