Options
All
  • Public
  • Public/Protected
  • All
Menu

Cryptopay-node - The official NodeJS library for the Cryptopay API Cryptopay is a payment gateway and business wallet that allows merchants to automate the processes of accepting cryptocurrency payments and payouts from their customers, as well as making currency exchange transactions and receiving data on the transaction history and account balance statuses for reporting.

For more information, please visit Cryptopay API docs.

Learn mode about API credentials at Developers guide

example
const { Cryptopay, SERVER } = require('cryptopay-node');
// Server is an optional parameter which is imported from constants.ts and switches between sandbox and production.
const api = new Cryptopay(api_secret, api_key, callback_secret, server, SERVER.sandbox);
api.accounts.list().then(console.log);

Hierarchy

  • Cryptopay

Index

Constructors

  • new Cryptopay(apiSecret: string, apiKey: string, callbackSecret: string, url?: string): Cryptopay
  • Parameters

    • apiSecret: string
    • apiKey: string
    • callbackSecret: string
    • Optional url: string

    Returns Cryptopay

Properties

accounts: { list: any; listTransactions: any }

Type declaration

channels: { create: any; list: any; listPayments: any; retrieve: any; retrieveByCustomId: any; retrievePayment: any; update: any }

Type declaration

coinWithdrawals: { commit: any; create: any; list: any; listNetworkFees: any; retrieve: any; retrieveByCustomId: any }

Type declaration

coins: { list: any }

Type declaration

customers: { create: any; list: any; retrieve: any; update: any }

Type declaration

exchangeTransfers: { commit: any; create: any; retrieve: any }

Type declaration

invoices: { commitRecalculation: any; create: any; createRecalculation: any; createRefund: any; list: any; listRefunds: any; retrieve: any; retrieveByCustomId: any }

An invoice is a request for a cryptocurrency payment which contains a unique BTC, LTC, ETH or XRP address and the amount that has to be paid while the invoice is valid.

example
//This endpoint allows you to retrieve a list of all invoices.
await cryptopay.invoices.list();

//This endpoint allows you to retrieve the invoice details by invoice id
await cryptopay.invoices.retrieve('invoice_id');

// This endpoint allows you to retrieve invoice details by its custom_id.
await cryptopay.invoices.retrieveByCustomId('custom_id');

//This endpoint allows you to recalculate invoices.
await cryptopay.invoices.createRecalculation('invoice_id', true)

// This endpoint allows you to commit invoice recalculation.
await cryptopay.invoices.commitRecalculation('invoice_id','recalculation_id')

//This endpoint allows you to create invoice refunds.
await cryptopay.invoices.createRefund('invoice_id')

//This endpoint allows you to retrieve a list of a particular invoice refunds.
await cryptopay.invoices.listRefunds('invoice_id')

Type declaration

  • commitRecalculation:function
    • This endpoint allows you to commit invoice recalculation.

      summary

      Commit invoice recalculation

      throws

      {RequiredError}

      Parameters

      • invoiceId: string

        Invoice ID

      • recalculationId: string

        Recalculation ID

      • Optional options: any

      Returns AxiosPromise<InvoiceRecalculationResult>

  • create:function
  • createRecalculation:function
  • createRefund:function
  • list:function
    • list(customerId?: string, startingAfter?: string, subscriptionId?: string, options?: any): AxiosPromise<InvoiceListResult>
    • This endpoint allows you to retrieve a list of all invoices.

      summary

      List invoices

      throws

      {RequiredError}

      Parameters

      • Optional customerId: string
      • Optional startingAfter: string
      • Optional subscriptionId: string
      • Optional options: any

      Returns AxiosPromise<InvoiceListResult>

  • listRefunds:function
    • This endpoint allows you to retrieve a list of a particular invoice refunds.

      summary

      List invoice refunds

      throws

      {RequiredError}

      Parameters

      • invoiceId: string

        Invoice ID

      • Optional options: any

      Returns AxiosPromise<InvoiceRefundListResult>

  • retrieve:function
    • retrieve(invoiceId: string, options?: any): AxiosPromise<InvoiceResult>
    • This endpoint allows you to retrieve the invoice details.

      summary

      Retrieve an invoice

      throws

      {RequiredError}

      Parameters

      • invoiceId: string

        Invoice ID

      • Optional options: any

      Returns AxiosPromise<InvoiceResult>

  • retrieveByCustomId:function
    • retrieveByCustomId(customId: string, options?: any): AxiosPromise<InvoiceResult>
    • This endpoint allows you to retrieve invoice details by its custom_id.

      summary

      Retrieve an invoice by custom_id

      throws

      {RequiredError}

      Parameters

      • customId: string
      • Optional options: any

      Returns AxiosPromise<InvoiceResult>

rates: { all: any; retrieve: any }
example
// Retrieve all rates
const resp = await cryptopay.rates.all();
// Retrieve a pair rate
const resp = await cryptopay.rates.retrieve("BTC/EUR");

Type declaration

  • all:function
    • This endpoint allows you to retrieve all public rates.

      summary

      Retrieve all rates

      throws

      {RequiredError}

      Parameters

      • Optional options: any

      Returns AxiosPromise<RatesResult>

  • retrieve:function
    • retrieve(baseCurrency: string, quoteCurrency: string, options?: any): AxiosPromise<RateResult>
    • This endpoint allows you to retrieve a public rate by currency pair.

      summary

      Retrieve a pair rate

      throws

      {RequiredError}

      Parameters

      • baseCurrency: string

        Base currency of pair

      • quoteCurrency: string

        Quote currency of pair

      • Optional options: any

      Returns AxiosPromise<RateResult>

transactions: { list: any }

Type declaration

url: string = SERVER.sandbox

Methods

  • verifyCallback(body: string, headers: Record<string, string>): boolean
  • Callbacks Documentation Every callback request contains a X-Cryptopay-Signature header which is needed to verify webhook body

    example
    // body must be json, headers are all your headers in response
    //if the callback is valid method returns true
    cryptopay.verifyCallback(body, headers)

    Parameters

    • body: string
    • headers: Record<string, string>

    Returns boolean

Generated using TypeDoc