Stripe.cancelSubscription()

Cancel an existing subscription attached to a customer.

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. Once this subscription is attached, you may use this machine to cancel the subscription at any time.

Usage

Hover over inputs/exits for more info.

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


// Cancel an existing subscription attached to a customer.

Stripe.cancelSubscription({

subscription: 'sub_someSubIdjsd2isnsd',

: ,

instant: true,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

subscription required

The subscription ID of the specific customers plan you wish to cancel.

'sub_someSubIdjsd2isnsd'
undefined

instant

Whether the subscription be cancelled instantly, or at the end of the subscription period. Defaults to `true`.

true

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 }