javascript - Update Subscription with Stripe & Parse Cloud Code -


i'm building app parse.com , stripe payment provider subscriptions.

i'm trying implement method update subscription plan. following stripe docs cloud code function looks 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) {    // , we're done!    response.success(subscription); }); 

});

when run function recieve error:

p…e.error {code: 141, message: "received unknown parameter: sub_xxxxxx"} 

sub_xxxx being right subscription id stored in user table. i'm stuck on several hours now. tried googling error couldn't find useful info....

has run before? or have working (cloud) code example this?

any appreciated!

thanks! seb

ok, got it:

apparently parse allows 1 subscription per user, therefore does't need(and doesn't allow) subscription id @ all. unfortunately parse cloud code not follow stripe api docs in case. parse had docs containing information - unfortunately link (which on net) no longer valid.

here's link copy of old documentation however: https://u.yunall.net/docs/js/symbols/stripe.customers.html

apparently still of use....


Comments