Skip to content

Instantly share code, notes, and snippets.

@elithrar
Created November 27, 2013 00:40
Show Gist options
  • Save elithrar/7668881 to your computer and use it in GitHub Desktop.
Save elithrar/7668881 to your computer and use it in GitHub Desktop.
Example Stripe Checkout - Custom Integration for #stripe
// Disable the payment/submit button until everything has loaded
// (if Stripe fails to load, we can't progress anyway)
$(document).ready(function() {
$("#payment-button").prop('disabled', false)
})
var handler = StripeCheckout.configure("customButtonA", {
key: '<yourpublishablekey',
token: function(token, args){
var $input = $('<input type=hidden name=stripeToken />').val(token.id);
$('form').append($input).submit();
}
});
('#payment-button').on('click', function(e){
$('#payment-button').prop('disabled', true);
setTimeout(function() {
$('#payment-button').prop('disabled', false);
}, 3000); // Sets a short timeout
handler.open({
amount: 7900,
image: "...",
name: "...",
description: "...",
panelLabel: "...",
currency: "...",
});
e.preventDefault();
});
@brettalton
Copy link

What if the dialogue is cancelled (not just closed, which is also called on success).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment