4.3.0 • Published 6 months ago

gocardless-nodejs v4.3.0

Weekly downloads
807
License
MIT
Repository
github
Last release
6 months 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.
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.
4.3.0

6 months ago

4.0.0

9 months ago

4.1.0

8 months ago

3.24.0

1 year ago

3.26.0

1 year ago

3.28.0

10 months ago

3.25.0

1 year ago

3.27.0

11 months ago

3.23.0

1 year ago

3.22.0

1 year ago

3.21.0

1 year ago

3.20.0

1 year ago

3.19.0

2 years ago

3.17.0

2 years ago

3.18.0

2 years ago

3.15.0

2 years ago

3.14.0

2 years ago

3.12.0

2 years ago

3.11.0

2 years ago

3.10.0

2 years ago

3.9.0

2 years ago

3.8.0

2 years ago

3.7.0

2 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

3.3.0

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

2.4.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.3.0

3 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.3

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago