Subscribe a customer to a pre-existing plan.

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](, each of which always fails in one predetermined ways.


Hover over inputs/exits for more info.

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

// Subscribe a customer to a pre-existing plan.


apiKey: 'somestring837483749blah',

plan: 'premium',

quantity: 20,

card: 'tok_someCardIdjsd2isnsd',

customer: 'cus_4kmLwU2PvQBeqq',


// An unexpected error occurred.

error: function (err) {



// OK.

success: function (newSubscription) {





apiKey required

Your Stripe API key

plan required

The plan id to subscribe the customer to.

quantity required

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

card required

The Stripe id of a saved card to charge.

customer required

The Stripe id of an existing customer to subscribe to the plan.




An unexpected error occurred.



{ id: 'sub_6EOW9GHkrQ53Z2',
   { interval: 'month',
     name: 'Gold Plan',
     created: 1431566401,
     amount: 2000,
     currency: 'gbp',
     id: 'gold',
     object: 'plan',
     livemode: false,
     interval_count: 1,
     trial_period_days: null,
     metadata: {},
     statement_descriptor: null },
  object: 'subscription',
  start: 1431505346,
  status: 'active',
  customer: 'cus_654EF6eI4JFErdS',
  cancel_at_period_end: false,
  current_period_start: 1431507646,
  current_period_end: 1434186046,
  ended_at: null,
  trial_start: null,
  trial_end: null,
  canceled_at: null,
  quantity: 2,
  application_fee_percent: null,
  discount: null,
  tax_percent: null,
  metadata: {} }