Parse.com Create Stripe Card Token In Cloud Code (main.js)
I am looking to create stripe token in parse cloud code.. I dont want to create token in client side HTML page. My complete web application is in HTML + Javascript so dont want to
Solution 1:
Finally my research is over and I got the solution:
Parse.Cloud.httpRequest({
method : 'POST',
url : 'https://api.stripe.com/v1/tokens',
headers : {
'Authorization' : 'Bearer sk_test_xxxxxxxxxxxxxx'
},
body : {
"card[number]" : request.params.number,
"card[exp_month]" : request.params.month,
"card[exp_year]" : request.params.year,
"card[cvc]" : request.params.cvc
},
success : function(httpResponse) {
token = httpResponse.data.id; // Its token which required for create payment/charge
},
error : function(httpResponse) {
// Error
}
})
The above code can be used in any cloud function which are written in main.js
Post a Comment for "Parse.com Create Stripe Card Token In Cloud Code (main.js)"