Skip to content

Instantly share code, notes, and snippets.

@rcdexta
Created April 30, 2016 04:27
Show Gist options
  • Save rcdexta/e4f24fa2b3d42b4907a423a5ea3b1824 to your computer and use it in GitHub Desktop.
Save rcdexta/e4f24fa2b3d42b4907a423a5ea3b1824 to your computer and use it in GitHub Desktop.
$(function() {
var expMonthAndYear = $('input[name=expiry]').val().split(" / ");
Stripe.card.createToken({
number: $('input[name=number]').val(),
cvc: $('input[name=cvv]').val(),
exp_month: expMonthAndYear[0],
exp_year: expMonthAndYear[1]
}, stripeResponseHandler);
});
var stripeResponseHandler = function(status, response) {
if (response.error) {
// Show appropriate error to user
} else {
// Get the token ID:
var token = response.id;
// Save token mapping it to customer for all future payment activities
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment