Skip to content

greenlamp3/rebilly-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rebilly node.js bindings Build Status

(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' }

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 test

Note: 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.