0.0.8 • Published 10 years ago
rebilly v0.0.8
Rebilly node.js bindings 
(Inspired by stripe-node)
Installation
npm install rebilly
Documentation
Documentation is available at https://www.rebilly.com/api/documentation/v2.1/.
API Overview
Every resource is accessed via your rebilly instance:
var rebilly = require('rebilly')(' your rebilly API key ');
// rebilly.{ RESOURCE_NAME }.{ METHOD_NAME }Every resource method accepts an optional callback as the last argument:
rebilly.customers.create(
{ email: 'customer@example.com' },
function(err, customer) {
err; // null if no error occurred
customer; // the created customer object
}
);Additionally, every resource method returns a promise, so you don't have to use the regular callback. E.g.
// Create a new customer and then a new charge for that customer:
rebilly.customers.create({
email: 'name@company.com'
}).then(function(customer) {
return rebilly.customers.update(customer.id, {
defaultCard: '4242'
});
}).then(function(charge) {
// New charge created on a new customer
}, function(err) {
// Deal with an error
});Available resources & methods
Where you see params it is a plain JavaScript object, e.g. { email: 'name@company.com' }
- customers
create(params)list([params])update(customerId[, params])retrieve(customerId)createSubscription(customerId, params)updateSubscription(customerId, subscriptionId, [, params])cancelSubscription(customerId, subscriptionId, [, params])listSubscriptions(params)createCard(customerId[, params])- [
createCardWithID(customerId, cardId[, params])](https://www.rebilly.com/sandbox/api/documentation/v2.1/#paymentCard-Create with given id) listCards(customerId)retrieveCard(customerId, cardId)authorize(customerId, cardId[, params])deactivate(customerId, cardId)listInvoices(customerId)- [
listTransactions(customerId[, params])](https://www.rebilly.com/sandbox/api/documentation/v2.1/#transaction-Retrieve Per Customer) - plans
create(params)list([params])update(planId[, params])retrieve(planId)del(planId)- tokens
create(params)retrieve(tokenId)expire(tokenId)- contacts
create(params)createWithID(contactId, params)(https://www.rebilly.com/api/documentation/v2.1/#contact-Create with specified ID)list()retrieve(contactId)- signature
generate(apiUser, apiKey)- invoices
create(params)modify|update(invoiceId, params)retrieve(invoiceId, params)void(invoiceId)abandon(invoiceId)issue(invoiceId, params)createItem(invoiceId, params)retrieveItems(invoiceId)- payments
create(params)retrieve(paymentId, params)list(params)- layouts
create(params)update(layoutId, params)retrieve(layoutId, params)list(params)
Configuration
rebilly.setApiKey(' your secret api key ');rebilly.setTimeout(20000); // in ms(default is node's default:120000ms)
Development
To run the tests you'll need a Rebilly Sandbox API key (from your Rebilly Dashboard):
$ npm install -g mocha
$ npm testNote: On Windows use SET instead of export for setting the REBILLY_TEST_API_KEY environment variable.
Author
Originally by Pedro Sampaio. Development was sponsored by Greenlamp.