Created
May 7, 2012 01:35
-
-
Save Poincare/2625346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment