Skip to content

Instantly share code, notes, and snippets.

@keikubo
Forked from michaelschade/gist:5053743
Created March 7, 2013 04:53
Show Gist options
  • Save keikubo/5105646 to your computer and use it in GitHub Desktop.
Save keikubo/5105646 to your computer and use it in GitHub Desktop.
var key = 'pk_test_czwzkTp2tactuLOEOqbMTRzG';
var params = {
'card[number]': '4242 4242 4242 4242',
'card[exp_month]': '01',
'card[exp_year]': '2050'
};
$.ajax({
url: 'https://api.stripe.com/v1/tokens',
method: 'POST',
dataType: 'json',
headers: {
'Authorization': 'Bearer ' + key
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
data: params
}).success(function (token) {
// We have a token
console.log(token);
}).error(function (ajax) {
if (ajax.responseText) {
console.log(JSON.parse(ajax.responseText));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment