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 do
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