Skip to content

Instantly share code, notes, and snippets.

@matthewarkin
Created September 16, 2015 18:24
Show Gist options
  • Save matthewarkin/7964878c493b658062c7 to your computer and use it in GitHub Desktop.
Save matthewarkin/7964878c493b658062c7 to your computer and use it in GitHub Desktop.
<html>
<body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://checkout.stripe.com/checkout.js"></script>
<form id="myForm" action="https://www.google.fr" method="POST">
<input type="text" id="amount" name="amount"/>
<input type="hidden" id="stripeToken" name="stripeToken"/>
<input type="hidden" id="stripeEmail" name="stripeEmail"/>
</form>
<input type="button" id="customButton" value="pay">
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
image: '/square-image.png',
token: function(token) {
alert(token.id);
}
});
$('#customButton').on('click', function(e) {
var amount = $("#amount").val() *100;
// Open Checkout with further options
handler.open({
name: 'Demo Site',
description: '2 widgets ($20.00)',
amount: amount
});
e.preventDefault();
});
// Close Checkout on page navigation
$(window).on('popstate', function() {
handler.close();
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment