npm install stripe
var api_key = 'abc'; // secret stripe API key
var stripe = require('stripe')(api_key);
stripe.customers.create(
{ email: 'foobar@example.org' },
function(err, customer) {
if (err) {
console.log(err.message);
return;
}
console.log("customer id", customer.id);
}
);
All methods takes a callback as their last parameter. The callback is
called with a Javascript Error
(if any) and then the response.
stripe.charges
- create, retrieve, refund and list charges.capture(charge_id, data)
- capture a charge, takes the optional parameter data (amount, application_fee).create(charge)
- create a charge.retrieve(charge_id)
- retrieve a charge by charge id.refund(charge_id, amount)
- refund a given charge, amount in cents.list(parameters)
- list charges
stripe.customers
- create, retrieve, update, delete and list customers.create(customer)
- create a customer, takes the data as an object.retrieve(customer_id)
- retrieve a customer by customer id..update(customer_id, updates)
- update a customer;updates
is an object with new parameters.del(customer_id)
- delete a customer.list({count:x,offset:y})
- list customers.update_subscription(customer_id, data)
- update subscription.cancel_subscription(customer_id, at_period_end)
- cancel subscription
stripe.plans
- create, retrieve, delete and list subscription plans.create(plan)
- create a plan, takes the data as an object.retrieve(plan_id)
- retrieve a plan by plan id..update(plan_id, data)
- update plan.del(plan_id)
- delete a plan.list({count:x,offset:y})
- list plans
stripe.invoices
- Invoices API.retrieve(invoice_id)
- retrieve an existing invoice.upcoming(customer_id)
- retrieve the upcoming invoice for a customer.list(parameters)
- list invoices
stripe.invoice_items
- create, retrieve, update, delete and list invoice items.create(invoice_item)
- create a invoice item, takes the data as an object.retrieve(invoice_item_id)
- retrieve a invoice item by invoice item id..update(invoice_item_id, updates)
- update a invoice item;updates
is an object with new parameters.del(invoice_item_id)
- delete a invoice item.list(customer_id, {count:x,offset:y})
- list invoice items; all parameters are optional
stripe.coupons
- create, retrieve, delete and list coupons.create(coupon)
- create a coupon, takes the data as an object.retrieve(coupon_id)
- retrieve a coupon by coupon id..del(coupon_id)
- delete a coupon.list({count:x,offset:y})
- list coupons
stripe.token
- Tokens API.create(card_data)
- create a token.retrieve(token_id)
- retrieve a card token
stripe.events
- retrieve and list events.retrieve(id)
- retrieve an event.list()
- list all events
Errors returned take the following format. Stripe Errors
{
name: "Stripe error type",
code: "Stripe error code",
param: "Stripe error param",
message: "Stripe error message"
}
See the issue tracker.
To run the tests, install vows with npm install vows
and then run
STRIPE_API=your-test-api-key vows test/*
Ask Bjørn Hansen (ask@develooper.com). Development was sponsored by YellowBot.
Copyright (C) 2011 Ask Bjørn Hansen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.