Stripe.createCharge()

Create a new charge for a customer

To charge a credit card, you create a new charge object. 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.

Usage

Hover over inputs/exits for more info.

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


// Create a new charge for a customer

Stripe.createCharge({

apiKey: 'somestring837483749blah',

amount: 500,

currency: 'usd',

card: 'tok_someCardIdjsd2isnsd',

capture: true,

description: 'This notable charge was for several gallons of mayonnaise!',

customer: 'cus_4kmLwU2PvQBeqq',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (newCharge) {

 

},

});

Inputs

apiKey required

Your Stripe API key

'somestring837483749blah'
amount required

The amount to charge, in the smallest currency unit (e.g. 500 to charge $5.00)

500
currency required

3-letter ISO code for currency.

'usd'
card required

The Stripe id of a saved card to charge.

'tok_someCardIdjsd2isnsd'
capture required

Whether to capture payment immediately, or just authorize it.

true
description

An arbitrary string to attach to the charge object in Stripe.

'This notable charge was for several gallons of mayonnaise!'
customer

The Stripe id of an existing customer to charge.

'cus_4kmLwU2PvQBeqq'

Exits

error

An unexpected error occurred.

success

OK.

{ id: 'ch_14Yged2eZvKYlo2CcRXx8khJ',
  object: 'charge',
  created: 1409761843,
  livemode: false,
  paid: true,
  amount: 500,
  currency: 'usd',
  refunded: false,
  card: 
   { id: 'card_14Yged2eZvKYlo2CacpQy0aC',
     object: 'card',
     last4: '4242',
     brand: 'Visa',
     funding: 'credit',
     exp_month: 1,
     exp_year: 2050,
     fingerprint: 'Xt5EWLLDS7FJjR1c',
     country: 'US',
     name: null,
     address_line1: null,
     address_line2: null,
     address_city: null,
     address_state: null,
     address_zip: null,
     address_country: null,
     cvc_check: 'pass',
     address_line1_check: null,
     address_zip_check: null,
     customer: null },
  captured: true,
  refunds: 
   { object: 'list',
     total_count: 0,
     has_more: false,
     url: '/v1/charges/ch_14Yged2eZvKYlo2CcRXx8khJ/refunds' },
  balance_transaction: 'txn_14WGN92eZvKYlo2Ccrcqvafr',
  failure_message: null,
  failure_code: null,
  amount_refunded: 0,
  customer: null,
  invoice: null,
  description: null,
  dispute: null,
  statement_description: null,
  receipt_email: null }