$( document ).ready(function() {
$(function() {
$.getScript('https://js.stripe.com/v2/', function() {
Stripe.setPublishableKey('pk_live_7yKPQhIqyrfYa54Q4YIZVxqK''pk_live_xxxxxxxxxxxxxxxxxxxxxxx');
});
$checkout_submit = $("#checkout_submit").click(function() {
if ($("[name='payment_method']").val() == "Stripe") {
$checkout_submit.attr('disabled', true);
Stripe.card.createToken(${(this.form), stripeResponseHandler);
return false;
}
});
function stripeResponseHandler(status, response) {
/* Re-enable the checkout submit button */
$checkout_submit.attr('disabled', false);
/* Check whether we have a valid credit card */
if (response.error) {
alert(response.error.message);
} else {
/* Set the card token and submit the checkout form */
$("#payment_token").val(response.id);
$checkout_submit.off("click").click();
}
}
});