Skip to content

Repository files navigation

Payments Gate NodeJS Client

This is a complete NodeJS module for communication with paymentsgate service.

Features

  • PayIn orders with out own widget (redirect)
  • Payin H2H (sync and async mode)
  • PayOut orders
  • Quotes (pre-payout quote calculate)
  • Account balance with pending funds
  • TRC20 deposit address requests

Dependencies

  • dayjs - lightweight library for date-time manipulation
  • jwt-decode - JWT parser

Usage

npm i @paymentsgate/nodejs-secure-api
import { ApiClient } from '@paymentsgate/nodejs-secure-api'; 

const client = new ApiClient({
  endpoint: 'https://api.example.com',
  filepath: './credentials.json'
});

//// .......... ////

const result = await client.createPayIn({
  amount: 10,
  currency: 'AZN',
  invoiceId: String(new Date().getTime()),
  clientId:  String(new Date().getTime()),
  successUrl: 'https://example.com/success',
  failUrl: 'https://example.com/fail',
  type: 'p2p'
});

The credentials.json file is used to connect to the client and contains all necessary data to use the API. This file can be obtained in your personal cabinet, in the service accounts section. Follow the instructions in the documentation to issue new keys. If you already have keys, but you don't feel comfortable storing them in a file, you can use client initialization via variables. In this case, the key data can be stored in external storage instead of on the file system:

import { ApiClient } from '@paymentsgate/nodejs-secure-api'; 

const client = new ApiClient({
  endpoint: 'https://api.example.com',
  accountId: '00000000-4000-4000-0000-00000000000a',
  publicKey: 'LS0tLS1CRUdJTiBSU0EgUFJJVkFUNSUlFb3dJQk....',
  privateKey: 'LS0tLS1CRUdJTiklqQU5CZ2txaGtpRzl3MEJBUUV....'
});

*It is important to note that the data format for key transfer is base46.

Examples

Request QUOTE

const result = await client.quote({
  currency_from: 'USDT',
  currency_to: 'AZN',
  amount: 5.20,
});

Response:

{
  id: "6462c5d3-3a50-4b7f-aae4-8e2e909d7a35"
  finalAmount: 8.41,
  direction: 'C2F',
  fullRate: 1.78,
  fullRateReverse: 0.021,
  fees: 0.5,
  fees_percent: 0.012,
  quotes: [
    {
      currencyFrom: 'USDT',
      currencyTo: 'AZN',
      pair: 'USDT/AZN',
      rate: 1.69
    },
  ]
}

Use QUOTE response for next request

const result = await client.createPayOut({
  currencyTo: 'EUR',
  amount: 5.20,
  baseCurrency: 'fiat',
  feesStrategy: 'add',
  invoiceId: 'INVOICE-112123123',
  recipient: {
    account_number: '4000000000000012',
    account_owner: 'CARD HOLDER',
    type: 'card'
  },
  quoteId: '6462c5d3-3a50-4b7f-aae4-8e2e909d7a35'
});

Available currencies

USDT EUR USD TRY CNY JPY GEL AZN INR AED KZT UZS TJS EGP PKR IDR BDT GBP RUB THB KGS PHP ZAR ARS GHS KES NGN AMD BYN TRX ETH XOF CAD AFN ALL AUD BAM BGN BHD BIF BND BOB BRL BWP BZD CDF CHF CLP COP CRC CVE CZK DJF DKK DOP DZD EEK ERN ETB GNF GTQ HKD HNL HRK HUF ILS IQD IRR ISK JMD JOD KHR KMF KRW KWD LBP LKR LTL LVL LYD MAD MDL MGA MKD MMK MNT MOP MUR MXN MYR MZN NAD NIO NOK NPR NZD OMR PAB PEN PLN PYG QAR RON RSD RWF SAR SDG SEK SGD SOS SYP TND TOP TTD TWD TZS UAH UGX UYU VEF VND YER ZMK

Available payment methods

p2p c2c m10 mpay sbp sbpqr iban upi imps spei pix rps ibps bizum rkgs kgsphone krungthainext sber kztphone bkash nagad alipay accountegp accountphp sberqr maya gcash banktransferphp banktransferars phonepe freecharge instapay instapayqr vodafonecash orangecash razn rtjs skzt scny vtbcny sgel seur stry sthb sberpay sberpay_s tpay opay moniepoint palmpay wave orangemoney orangemoneyjod moovmoney rtjscard ruzs amobile payid baridi multiwidget banktransfermad cih cashplus elqr odengi banktransferdop sinpemovil tryqr bsb banktransfermnt stcpay upiqr ifsc tjsbank sortgbp unionpay ecomazn ecomrub banktransferthb banktransferzar dcecomusd dcecomeur benefitpay cliq papara blik promptpayqr applepay ideal napas vndqr inrqr egpqr oneclick thaiqr mobilecom banktransferuyu banktransferngn mpesa airtel equitel fib

About

Payments Gate Secure API client

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages