How would you convert the following code into Parse REST http request?
curl https://api.stripe.com/v1/charges \
-u {PLATFORM_SECRET_KEY}: \
-H "Stripe-Account: {CONNECTED_STRIPE_ACCOUNT_ID}" \
-d amount=1000 \
-d currency=aud \
-d source={TOKEN}
I've attempted the following but am receiving 401 authorization errors:
Parse.Cloud.define("payMerchantDirect", function(request, response){
Parse.Cloud.httpRequest({
method: "POST",
url: "https://" + {PLATFORM_SECRET_KEY} + ':@' + "api.stripe.com/v1" + "/charges/",
headers: {
"Stripe-Account": request.params.{CONNECTED_STRIPE_ACCOUNT_ID}
},
body: {
'amount': 1000,
'currency': "aud",
'source': request.params.{TOKEN}
},
success: function(httpResponse) {
response.success(httpResponse.text);
},
error: function(httpResponse) {
response.error('Request failed with response code ' + httpResponse.status);
}
});
});
I've triple checked the Stripe keys and IDs used, but alas still not working. Is it correct to place the -u cURL variable in the url?
Cheers, Eric