Skip to content

saudslm/recharge-api-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recharge API Node.js

Recharge API bindings for Node.js

Installation:

$ npm install --save recharge-api-node

API

This module exports a constructor function which takes an options object.

Recharge(options)

Creates a new Recharge instance.

Arguments

  • options - Required - A plain JavaScript object that contains the configuration options.

Options

  • apiKey - Required - A string that specifies the API key of the app.
  • secrete - A string that specifies the secrete of the app.
  • autoLimit - Optional - This option allows you to regulate the request rate in order to avoid hitting the [rate limit][api-call-limit]. Requests are limited using the token bucket algorithm. Accepted values are a boolean or a plain JavaScript object. When using an object, the calls property and the interval property specify the refill rate and the bucketSize property the bucket size. For example { calls: 2, interval: 1000, bucketSize: 35 } specifies a limit of 2 requests per second with a burst of 35 requests. When set to true requests are limited as specified in the above example. Defaults to false. presentment prices for products. Defaults to false.
  • timeout - Optional - The number of milliseconds before the request times out. If the request takes longer than timeout, it will be aborted. Defaults to 60000, or 1 minute.

Return value

A Recharge instance.

Exceptions

Throws an Error exception if the required options are missing.

Example

const Recharge = require('recharge-api-node');

const recharge = new Recharge({
  apiKey: 'your-api-key',
  secrete: 'your-app-secrete'
});

Resources

Every resource is accessed via your recharge instance:

const recharge = new Recharge({
  apiKey: 'your-api-key',
  secrete: 'your-app-secrete'
});

// recharge.<resource_name>.<method_name>

Each method returns a Promise that resolves with the result:

recharge.subscription
  .list({ limit: 5 })
  .then((subscriptions) => console.log(subscriptions))
  .catch((err) => console.error(err));

Available resources and methods

  • address
    • count()
    • list([params])
    • get(id[, params])
    • update(id, params)
    • delete(id)
    • validate(params)
    • addDiscount(id, params)
    • removeDiscount(id, params)
    • addOneTimeProduct(id, params)
  • asyncBatch
    • list([params])
    • get(id[, params])
    • create(params)
    • addTasks(batch_id, params)
    • tasks(batch_id)
    • process(batch_id)
  • charge
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • changeNextChargeDate(id, params)
    • skip(id, params)
    • unskip(id, params)
    • refund(id, params)
    • addDiscount(id, params)
    • removeDiscount(id, params)
  • checkout - BETA - **query_params object can be used in case of partial_shipping ex: {partial_shipping: 1}
    • get(checkout_token[, params])
    • create(params[, query_params])
    • update(checkout_token, params[, query_params])
    • getShippingRates(checkout_token)
    • process(checkout_token, params)
  • collection
    • count()
    • list([params])
    • get(id[, params])
  • customerAddress
    • list(customer_id[, params])
    • create(customer_id, params)
  • customer
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • getPaymentSources(id)
  • discount
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • addToAddress(address_id[, params])
    • removeFromAddress(address_id[, params])
    • addToCharge(charge_id[, params])
    • removeFromCharge(charge_id[, params])
  • metafield
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
  • oneTime
    • list([params])
    • get(id[, params])
    • create(address_id, params)
    • update(id, params)
    • delete(id)
  • order
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • changeShippingDate(id, params)
    • changeOrderVariant(id, shopify_variant_id, params)
    • clone(id, charge_id, params)
  • product
    • count()
    • list([params])
    • get(id[, params])
  • shop
    • get()
    • getShippingCountries()
  • subscription
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • changeNextChargeDate(id, params)
    • changeAddress(id, params)
    • cancel(id, params)
    • activate(id)
    • ** 'swap product' end point can be triggered using 'update()' function
  • webhook
    • count()
    • list([params])
    • get(id[, params])
    • create(params)
    • update(id, params)
    • delete(id)
    • validate(request_body, secrete)

where params is a plain JavaScript object. See https://developer.rechargepayments.com/#webhooks for parameters details.

Releases

No releases published

Packages

No packages published