I'm currently building an app with parse.com and stripe as payment provider for subscriptions.
I'm trying to implement a method to update a subscription plan. Following the stripe docs my cloud code function looks like this:
Parse.Cloud.define("stripeChangeSub", function(request, response) {
var currentUser = Parse.User.current();
var customer = currentUser.get('stripeCustomerId');
var subscriptionId = currentUser.get('stripeSubscriptionId');
var newPlan = request.params.plan;
var userProrate = request.params.prorate;
var stripeToken = request.params.token;
Stripe.Customers.updateSubscription(
customer,
subscriptionId,
{ plan: newPlan,
prorate: userProrate,
source: stripeToken})
.then(null, function(error) {
response.error(error.message);
}).then(function(subscription) {
// And we're done!
response.success(subscription);
});
});
When I run the function I recieve this error:
P…e.Error {code: 141, message: "Received unknown parameter: sub_XXXXXX"}
sub_XXXX being the right subscription id I stored in my user table. I'm stuck on this for several hours now. I tried googling the error but couldn't find any useful info....
Has anyone run into this before? Or does anyone have a working (cloud) code example for this?
Any help would be much appreciated!
Thanks! Seb
Ok, I got it:
Apparently parse only allows one subscription per user, therefore it does't need(and doesn't allow) the subscription ID at all. So unfortunately parse cloud code does not follow the stripe api docs in this case. Parse actually had docs containing this information - unfortunately the link to that (which is all over the net) is no longer valid.
Here's is a link to a copy of the old documentation however: https://u.yunall.net/docs/js/symbols/Stripe.Customers.html
Apparently it is still of use....