0.11.3 • Published 1 year ago

paymentrails v0.11.3

Weekly downloads
249
License
ISC
Repository
-
Last release
1 year ago

DEPRECATED

Trolley JavaScript SDK (Previously Payment Rails^1)

Trolley's now DEPRECATED JavaScript SDK. New package: trolleyhq

New SDK available at : https://www.npmjs.com/package/trolleyhq

Update notification and details: https://trolley.com/updates/eol-paymentrails-sdks/


For more information about the API as well as NodeJS code samples check out the full API documentation

^1: Payment Rails is now Trolley. We're in the process of updating our SDKs to support the new domain. In this transition phase, you might still see "PaymentRails" at some places.

Installation

npm install --save paymentrails

Getting Started

The Trolley API is built using promises and all methods except connect will return a promise. The connect call allows you to setup your API Key and Secret with a client that can be used for subsequent calls.

// A simple application using the Trolley/Payment Rails SDK
const trolley = require('paymentrails');

const client = trolley.connect({
  key: "YOUR-API-KEY",
  secret: "YOUR-API-SECRET",
  environment: "production",
});

// Async/Await version

async function main() {
  const recipient = await client.recipient.find("R-G7SXXpm6cs4aTUd9YhmgWC");
  console.log(recipient.id);
}

main();

// Promise version

client.recipient.find("R-G7SXXpm6cs4aTUd9YhmgWC").then(recipient => {
  console.log(recipient.id);
}).catch(err => {
  console.log("ERROR", err);
});

Usage

Methods should all have JSDoc comments to help you understand their usage. As mentioned the full API documentation is the best source of information about the API.

For more information please read the JavaScript API docs is available. The best starting point is:

Data TypeSDK Documentation
BatchAPI Docs for Batch
PaymentAPI Docs for Payment
RecipientAPI Docs for Recipient
Recipient AccountAPI Docs for Recipient Account

Running Integration / Unit tests

If you're working on the library itself, here's easy way to run the tests.

// if not already, copy the example env file to create an env file
$ cp .env.test .env

// Set access key and secret in the env file
TROLLEY_ENVIRONMENT="production"
TROLLEY_ACCESS_KEY="ACCESS_KEY"
TROLLEY_SECRET_KEY="SECRET_KEY"

//Run the fixture based tests
$ npm test
0.11.2

1 year ago

0.11.3

1 year ago

0.11.1

1 year ago

0.11.0

2 years ago

0.10.3

3 years ago

0.10.2

4 years ago

0.9.7

5 years ago

0.9.6

6 years ago

0.9.5

6 years ago

0.9.4

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago