How to charge Stripe customer from server code.
I'm trying to use server code to charge an already created customer using reference to the customer# (not the card token). Here's what I've tried (unsuccessfully):
pre
var url = "https://api.stripe.com/v1/charges/";
var postData = {
"parameters": {
"currency": "usd",
"amount": 1200,
"customer": "cus_XXXXXXXXXXXX"
},
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer sk_test_XXXXXXXXXXXXXXXXXXXXX"
}
};
var XHRResponse = XHR.send("POST", url, postData);
response.success(XHRResponse, "json");
/pre
I then noticed that Appery uses a proxy to invoke the Stripe_charge service. Can I call the Appery proxy from server code? If so, how would I do that, passing the appropriate json info about the transaction?
pre
var StripePayment_Settings = {
"apiKey": "sk_test_XXXXXXXXXXXXXXXXXXXXX",
"token": "token"
}
var url = "https://api.appery.io/rest/1/proxy/tunnel";
var postData = {
"proxyHeaders": {
'appery-proxy-url': 'https://api.stripe.com/v1/charges',
'appery-transformation': 'checkTunnel', //is this where I'd send a json object?
'appery-key': '1422474530915',
'appery-rest': '2615010'
},
'dataType': 'json',
'type': 'post',
'contentType': 'application/x-www-form-urlencoded',
'serviceSettings': StripePayment_Settings
};
var XHRResponse = XHR.send("POST", url, postData);
response.success(XHRResponse, "JSON");
/pre
Any help would be appreciated...
Thank you for the direction!