Reputation: 135
I'm currently trying to implement Stripe in my app, but it looks like the Stripe Cloud module of Parse is missing an important part.
From the Stripe docs:
Stripe offers the ability to subscribe a single customer object to multiple subscriptions. Each subscription will have a unique ID and its state is handled independently from other subscriptions.
And to do that, you should use stripe.customers.createSubscription
But there is no createSubscription method in Stripe.Customers on parse. https://www.parse.com/docs/js/symbols/Stripe.Customers.html
I just don't understand how to achieve that.
Actually, you can't even subscribe to a plan without creating a new customer.
Thanks for any help you can provide. And please excuse me for my english, this is not my mother tongue.
Upvotes: 1
Views: 173
Reputation: 66
Was having exactly the same issue. The answer was to do it with an httpRequest.
var stripeKey = "sk_test_your_secret_key"
Parse.Cloud.define("subscribeCustomerToPlan", function(request, response) {
Parse.Cloud.httpRequest({
method:"POST",
url: "https://" + stripeKey + ":@api.stripe.com/v1/customers/" + request.params.customerId + "/subscriptions",
body:{
"plan": request.params.plan
},
success: function(httpResponse) {
response.success(httpResponse);
},
error: function(httpResponse) {
response.error('Request failed with response code ' + httpResponse.status);
}
});
});
Upvotes: 3