-
-
Save keikubo/5105646 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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