Skip to content

Payment Rails JavaScript SDK for v1 API

Notifications You must be signed in to change notification settings

aquast1/javascript-sdk

 
 

Repository files navigation

Payment Rails1 JavaScript SDK

A JavaScript SDK (written in TypeScript) - For more information about the API as well as NodeJS code samples check out the full API documentation

Installation

npm install --save paymentrails

Getting Started

The Payment Rails 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 Payment Rails SDK
const paymentrails = require('paymentrails');

const client = paymentrails.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 Type SDK Documentation
Batch API Docs for Batch
Payment API Docs for Payment
Recipient API Docs for Recipient
Recipient Account API Docs for Recipient Account

Running Integration / Unit tests

If you're working on the library itself, here's easy way to run the unit tests. They are designed to be run with configuration coming through environment variables.

  • PR_ACCESS_KEY
  • PR_SECRET_KEY
  • PR_ENVIRONMENT

For a command like:

PR_ACCESS_KEY=xxx \
PR_SECRET_KEY=yyy \
PR_ENVIRONMENT=integration \
npm run test:integration

Footnotes

  1. Payment Rails is now Trolley, we'll be updating our SDKs to support the new domain during the first half of 2022.

About

Payment Rails JavaScript SDK for v1 API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%