3.23.0 • Published 7 days ago

gocardless-nodejs v3.23.0

Weekly downloads
807
License
MIT
Repository
github
Last release
7 days ago

Node.js client for the GoCardless API

GoCardless npm version

A Node.js client for the GoCardless API. For full details of the GoCardless API, see the API docs.

Installation

$ npm i gocardless-nodejs

Usage

Initialising the client

To initialise the client, you must provide:

  • An access token.
  • The environment that this token is for (see here for a list of available environments).
  • Any additional options (see here for a list of supported options).
const gocardless = require('gocardless-nodejs');
const constants = require('gocardless-nodejs/constants');


// Initialise the client.
const client = gocardless(
  process.env.GC_ACCESS_TOKEN,
  constants.Environments.Sandbox,
  { raiseOnIdempotencyConflict: true },
);

The Basics

We'll illustrate the basic library usage by demonstrating on the payment resource.

For a full list of available resources, visit the GoCardless API reference.

const uuidv4 = require('uuid/v4');

// Create a new payment with an idempotency key
const payment = await client.payments.create(
  {
    amount: 100,
    currency: "GBP",
    links: { mandate: "MD123" },
  },
  uuidv4(),
);

// List the first three payments past a certain date.
const payments = await client.payments.list({
  limit: 3,
  created_at: {
    gt: '2020-01-01T17:01:06.000Z',
  },
});

// Get a payment.
const payment = await client.payments.find('PM123');

// Update a payment.
await client.payments.update('PM123', { amount: '22' });

// Cancel a payment.
await client.payments.cancel('PM123');

The all method

All resources with a list method will also have an additional *all method. This method acts like the regular list method and accepts the same parameters, but instead returns an async generator.

for await (const payment of client.payments.all()) {
  console.log(payment.id);
}

Available client options

  • raiseOnIdempotencyConflict: set to true to raise exceptions on idempotency conflicts. Defaults to false.
3.23.0

7 days ago

3.22.0

22 days ago

3.21.0

4 months ago

3.20.0

4 months ago

3.19.0

5 months ago

3.17.0

7 months ago

3.18.0

6 months ago

3.15.0

8 months ago

3.14.0

12 months ago

3.12.0

1 year ago

3.11.0

1 year ago

3.10.0

1 year ago

3.9.0

1 year ago

3.8.0

1 year ago

3.7.0

1 year ago

3.6.1

1 year ago

3.6.0

1 year ago

3.5.0

1 year ago

3.4.0

2 years ago

3.3.0

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

2.4.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.3.0

2 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago