stripe-node icon indicating copy to clipboard operation
stripe-node copied to clipboard

stripe.customers.cancelSubscription unable to take at_period_end parameter

Open damien-m opened this issue 11 years ago • 4 comments

API Signature only accepts {CUSTOMER_ID}, {SUBSCRIPTION_ID}, Unable to pass at_period_end

damien-m avatar Jan 18 '15 06:01 damien-m

@damien-m - You should be able to pass at_period_end inside the optional arguments object as a third parameter, e.g.

stripe.customers.cancelSubscription('customerId', 'subscriptionId', {at_period_end: true});

Passing optional arguments is documented here: https://github.com/stripe/stripe-node/wiki/Passing-Options

(also see: https://github.com/stripe/stripe-node/blob/master/test/resources/Customers.spec.js#L698-L710)

stephen avatar Jan 18 '15 14:01 stephen

The third parameter for this method is a callback function. Passing an options argument as the third argument prevents this from being called. It would be good to get a response and handle that appropriately.

damien-m avatar Jan 19 '15 02:01 damien-m

Hmm, to clarify, you can pass in the callback as a fourth parameter when using the optional arguments object (as the third parameter). Would look something like this:

stripe.customers.cancelSubscription('customerId', 'subscriptionId', { at_period_end: true }, function(err, data) {
  console.log(err, data);
});

(fwiw, I just tested this gist - script and output: https://gist.github.com/stephen/e49da7bd005b41fc5c13)

stephen avatar Jan 19 '15 14:01 stephen

Ok thanks. I'll RTFM next time :wink:

damien-m avatar Jan 19 '15 22:01 damien-m