npm install fingerfoodstudios/fusebill-node
Documentation is NOT available the API documentation is here http://help.fusebill.com/api-resource-urls
Every resource is accessed via your fusebill
instance:
var fusebill = require('fusebill')(' your fusebill API key ');
// fusebill.{ RESOURCE_NAME }.{ METHOD_NAME }
Every resource method accepts an optional callback as the last argument:
fusebill.customers.create(
{ primaryEmail: '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:
fusebill.customers.create({
primaryEmail: 'foo-customer@example.com'
}).then(function(customer) {
return fusebill.subscription.create({
customerId: customer.id,
planFrequencyId: 9999
});
}).then(function(charge) {
// New charge created on a new customer
}).catch(function(err) {
// Deal with an error
});
To use the Fusebill-Account
header, simply pass an extra options hash:
// Retrieve the balance for a connected account:
fusebill.balance.retrieve({
fusebill_account: "acct_foo"
}).then(function(balance) {
// The balance object for the connected account
}).catch(function(err) {
// Error
});
STILL A WORK IN PROGRESS
Where you see params
it is a plain JavaScript object, e.g. { email: 'foo@example.com' }
- customers
create(params)
list([params])
update(customerId[, params])
retrieve(customerId)
listSubscriptions(customerId)
listEmailPreferences(customerId)
listInvoices(customerId)
listDraftInvoices(customerId)
- customerActivation
activate(customerId)
- customerAddressPreferences
retrieve(customerId)
- customerBillingSettings
- customerEmailPreferences
- draftInvoices
- invoices
retrieve(invoiceId)
retrievePdf(invoiceId)
- paymentMethods
- plans
list([params])
retrieve(planId)
listProducts(planId)
retrieveProducts(planId)
- planProducts
- products
list([params])
retrieve(productId)
- purchases
- subscriptions
create(params)
list([params])
update(subscriptionID[, params])
retrieve(subscriptionId)
del(subscriptionId)
- subscriptionActivation
activate(subscriptionId)
fusebill.setApiKey(' your secret api key ');
fusebill.setTimeout(20000); // in ms
(default is node's default:120000ms
)
- NOTE Tests are NOT working *
Run the tests using
npm
:
$ npm install
$ npm test
If you wish, you may run tests using your Fusebill Test API key by setting the environment variable STRIPE_TEST_API_KEY
before running tests:
$ export FUSEBILL_TEST_API_KEY='sk_test....'
$ npm test
Note: On Windows use SET
instead of export
for setting the FUSEBILL_TEST_API_KEY
environment variable.
Originally by Ask Bjørn Hansen (ask@develooper.com). Development was sponsored by YellowBot. Adapted for Fusebill by Justin Hamade