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