public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
function stripeResponseHandler(status, response) {
 
if (response.error) {
$(".payment-errors").text(response.error.message);
}
else {
var form$ = $("#stripe-form");
var token = response['id'];
form$.append("<input type='hidden' name='stripeToken' value='" + token + "'/>");
form$.get(0).submit();
}
}
 
$(document).ready(function() {
$("#stripe-form").submit(function(event) {
$('.submit').attr("disabled", "disabled");
 
Stripe.createToken({
number: $('.credit-number').val(),
cvc: $('.credit-security').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);
 
// prevent the form from submitting with the default action
return false;
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.