1.3.3 • Published 5 months ago

cryptopay v1.3.3

Weekly downloads
3
License
MIT
Repository
github
Last release
5 months ago

Cryptopay

The unofficial Node.js library for the Cryptopay API.

npm version npm ci

Credentials

In order to use the Cryptopay API, you need to register on their website. After registration, you can create API keys. Create one and provide the details from that to the constructor function.

Usage

Installation

npm i cryptopay

Setup

const CryptopayClient = require("cryptopay");

const client = new CryptopayClient({
  apiKey: "api key here", // Your Cryptopay API Key
  apiSecret: "api secret here", // Your Cryptopay API Secret
  sandbox: false // Uses sandbox/development endpoints if true
});

Methods

getAllRates()

Get all public rates for cryptocurrencies.

Parameters

None

Returns

  • Promise (Multiple Objects with buy_rate and sell_rate keys)

Example

client.getAllRates().then(rates => {
  //...do something with the rates
});

getPairRate()

Get rate for a specific cryptocurrency pair.

Parameters

ParameterTypeRequiredDescription
Pairstring+Currency pair e.g. BTCEUR

Returns

  • Promise (Object with buy_rate and sell_rate keys)

Example

client.getPairRate("BTCEUR").then(rate => {
  //...do something with the rate
});

getAccounts()

Get all user created accounts.

Parameters

None

Returns

  • Promise (Array of AccountObject's)

Example

client.getAccounts().then(accounts => {
  //...do something with the accounts
});

getAccountTransactions()

Get all account transactions.

Parameters

ParameterTypeRequiredDescription
Account IDstring+Account ID from cryptopay

Returns

  • Promise (Array of TransactionObject's)

Example

client
  .getAccountTransactions("91202339-52e2-432d-8078-12d49d96ce02")
  .then(transactions => {
    //...do something with the transactions
  });

createChannel()

Create channel and crypto address for the user

Parameters

ParameterTypeRequiredDescription
pay_currencystring+The cryptocurrency which you want to accept
receiver_currencystring+The currency which all incoming transactions will be converted to
custom_idstring+Custom ID to indentify channel
namestringChannel name
descriptionstringChannel description

Returns

  • Promise (ChannelObject)

Example

client
  .createChannel({
    pay_currency: "BTC",
    receiver_currency: "EUR",
    custom_id: "123456",
    name: "Deposit",
    description: "Deposit Address for User X"
  })
  .then(channel => {
    //...do something with the channel
  });

getAllChannels()

Get all channels created

Parameters

None

Returns

  • Promise (Array of ChannelObject's)

Example

client.getAllChannels().then(channels => {
  //...do something with the channels
});

getChannelPayments()

Get all specific channel payments

Parameters

ParameterTypeRequiredDescription
Channel IDstring+Channel ID

Returns

  • Promise (Array of PaymentObject's)

Example

client
  .getChannelPayments("50eb5775-f77e-4c64-870b-dc93624b5967")
  .then(channels => {
    //...do something with the channels
  });

createCoinPayment()

Create a coin withdrawal payment

Parameters

ParameterTypeRequiredDescription
charged_currencystring+An account currency to send a transaction from
received_currencystring+Cryptocurrency type
charged_amountnumber+All applicable fees will be deducted from this amount
addressstring+A recipient's cryptocurrency wallet address
custom_idstring+Payment reference ID in your system

Returns

  • Promise (PaymentObject)

Example

client
  .createCoinPayment({
    charged_currency: "EUR",
    received_currency: "BTC",
    charged_amount: 10,
    address: "2N122JKRz52gokTmaVYNiMA43qvdSqnhLGV",
    custom_id: "123456"
  })
  .then(payment => {
    //...do something with the payment
  });

commitCoinPayment()

Commit a coin withdrawal payment

Parameters

ParameterTypeRequiredDescription
Payment IDstring+Payment ID

Returns

  • Promise (PaymentObject)

Example

client
  .commitCoinPayment("50eb5775-f77e-4c64-870b-dc93624b5967")
  .then(payment => {
    //...do something with the payment
  });

Objects

AccountObject

ParameterTypeDescription
idstringAccount ID
balancestringAccount balance
currencystringAccount currency
project_idstringProject ID which the account belongs to. Learn more about projects

TransactionObject

ParameterTypeDescription
idstringAccount transaction ID
custom_idstringTransaction custom_id
amountstringTransaction amount
currencystringTransaction currency
balancestringAccount subtotal
feestringTransaction fee details
fee_currencystringTransaction fee currency
referecnce_idstringTransaction reference ID in Cryptopay
reference_typestringTransaction type
descriptionstringTransaction description
statusstringTransaction status
status_contextstringTransaction status context
created_atstringTransaction creation date and time

ChannelObject

ParameterTypeDescription
idstringChannel ID
namestringChannel name
descriptionstringChannel description
receiver_currencystringThe currency which all incoming transactions will be converted to
pay_currencystringThe cryptocurrency which you want to accept
addressstringChannel cryptocurrency address
project_idstringProject ID. Learn more about projects
custom_idstringThe channel reference ID in your system
uristringChannel URI. May be used for generating a QR code
hosted_page_urlstringChannel hosted page that renders channel details

PaymentObject

ParameterTypeDescription
idstringChannel payment ID
paid_amountstringCryptocurrency transaction amount that was received
paid_currencystringCryptocurrency type
received_amountstringAmount credited to your Cryptopay account
received_currencystringAccount currency
feestringProcessing fee
fee_currencystringProcessing fee currency
txidstringCryptocurrency transaction ID on the blockchain
exchangeobjectExchange details
-pairstringCurrency pair
-ratestringExchange rate
-feestringExchange fee
-fee_currencystringExchange fee currency
statusstringChannel payment status. Refer to a list of channel payment statuses
custom_idstringChannel payment custom_id value inherited from its parent channel
channel_idstringChannel ID
addressstringChannel cryptocurrency address
riskObjectCryptocurrency transaction risk level details
-scorenumberTransaction risk score
-levelstringTransaction risk level. low, medium or high depending on the score value
-resource_namestringA resource name the transaction has been received from e.g. Bitstamp
-resource_categorystringA resource category the transaction has been received from e.g. Exchange
created_atstringChannel payment creation date and time
1.3.3

5 months ago

1.3.2

11 months ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago