Stripe.updateSubscription()

Update a customer's subscription to change plan or quantity.

To subscribe a customer, you must first create a customer object with a saved card and a subscription plan (You can do this in your Stripe control panel). If your API key is in test mode, the supplied card won't actually be charged, though everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully). Also note that you can use one of the [test cards provided by Stripe](https://stripe.com/docs/testing#cards), each of which always fails in one predetermined ways. Until this has been done, you cannot update a subscription (In other words, don't use this machine to create a subscription)

Usage

Hover over inputs/exits for more info.

var Stripe = require('machinepack-stripe');


// Update a customer's subscription to change plan or quantity.

Stripe.updateSubscription({

subscription: 'sub_someSubIdjsd2isnsd',

: ,

plan: 'premium',

quantity: 20,

coupon: 'HALFOFF',

trialEnd: 1471583633,

prorate: true,

prorationDate: 1471583633,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

subscription required

The subscription ID of the specific customer's plan.

'sub_someSubIdjsd2isnsd'
undefined

plan

The plan ID to subscribe the customer to.

'premium'
quantity

If using a plan with multiple users or other dynamic elements, specify the quantity.

20
coupon

The code of a coupon to apply to this subscription.

'HALFOFF'
trialEnd

Timestamp representing the end of the trial period the customer will get before being charged for the first time.

1471583633
prorate

Whether the subscription should be prorated with respect to changes in plan, quantity or trial length. Defaults to `true`.

true
prorationDate

If set, the proration will be calculated as though the subscription was updated at the given time.

1471583633

Exits

error

An unexpected error occurred.

success

OK.

{ id: 'sub_929dHmk5spqvgi',
  object: 'subscription',
  application_fee_percent: 0,
  cancel_at_period_end: false,
  canceled_at: 0,
  created: 1471583633,
  current_period_end: 1474262033,
  current_period_start: 1471583633,
  customer: 'cus_92418YMzH9wiaI',
  discount: 0,
  ended_at: 0,
  livemode: false,
  metadata: {},
  plan: 
   { id: 'pro',
     object: 'plan',
     amount: 3000,
     created: 1471559116,
     currency: 'usd',
     interval: 'month',
     interval_count: 1,
     livemode: false,
     metadata: {},
     name: 'Pro',
     statement_descriptor: 'Pro Plan',
     trial_period_days: 0 },
  quantity: 1,
  start: 1471583633,
  status: 'active',
  tax_percent: 0,
  trial_end: 0,
  trial_start: 0 }