Skip to content

Instantly share code, notes, and snippets.

@namlet
Last active August 29, 2015 14:01
Show Gist options
  • Save namlet/242ceca8b6a4a018879f to your computer and use it in GitHub Desktop.
Save namlet/242ceca8b6a4a018879f to your computer and use it in GitHub Desktop.
<script>
var handler = StripeCheckout.configure({
key: '*****',
//image: '/square-image.png',
token: function(token, args) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
console.log(token);
console.log(args);
var pkg = {'token':token, 'args':args};
$.post('/stripe/charge', pkg, function(data){
console.log("RETURN from server");
console.log(data);
location.href = "thankyou.html";
});
}
});
$('.btn-buy').click(function(e) {
// Open Checkout with further options
handler.open({
name: 'My Teen Driver',
description: '3 Years of Service and Window Stickers',
image: 'img/logo-car.png',
billingAddress: true,
shippingAddress: true,
amount: 3999
});
e.preventDefault();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment