So I am just about finished with integrating Stripe Connect with Parse Cloud Code and a Django web app.
Currently, Parse hasn't implemented the Stripe module method to generate tokens given an access token and a customer id. So I need to do this myself.
I run the cURL command that Stripe API provides you to see an example response, here it is,
curl https://api.stripe.com/v1/tokens \
-u theaccesstoken: \
-d customer=customersid
So I get a response and everything is going good. But I am now trying to mimic this behavior within Parse.Cloud.httpRequest.
Here is my attempt to generate the command:
var retrieveToken = function(url, accessToken, customerId) {
var promise = new Parse.Promise();
Parse.Cloud.httpRequest({
method: 'POST',
header : {'access_token' : accessToken},
url: url,
body : {'customer':customerId},
success: function(httpResponse) {
promise.resolve(httpResponse);
},
error: function(httpResponse) {
promise.reject(httpResponse);
}
});
return promise;
}
The response returns 'Creating token with stripe failed. Error: [object Object]' the message comes from:
return retrieveToken(tokenURL, accessToken, customerId).then(null, function(error) {
console.log('Creating token with stripe failed. Error: ' + error);
return Parse.Promise.error('An error has occurred. Your credit card was not charged.');
});
My issue is generally generating the httpRequest. Anyone have any ideas on how to create the correct httpRequest?