Description
Enable cryptocurrency payments in your web applications or business.
This NODE SDK interacts with the Coinpush.io API handling the creation and monitoring of cryptocurrency payments.
Contents
Prerequisites
- NODE >= 8.0.0
- NPM
Installation
npm install coinpush-node
Usage
Currencies
Coinpush currently supports: btc
, bch
and ltc
.
Be sure to check out Coinpush's supported cryptocurrencies for an up-to-date list, as well as fee information.
Initialisation
To get started, inject the Config
class into the Client
constructor:
const Config = 'config'const Client = 'client'const Coinpush =
Testnet
Want to request the Coinpush.io Testnet? Enable it like so:
const Coinpush =
IMPORTANT: Please do not send real payments to any addresses created on the Testnet, as our systems do not monitor them automatically.
Approach A
This approach enables payments on a per-cryptocurrency basis.
Payment Creation
To create a new payment address, use the following method:
let currency = 'btc' // The cryptocurrency to charge in. Coinpush
For more information on the create
resource visit: Coinpush.io API Payment Creation.
Payment Monitoring
Webhooks
Webhook notifications are sent if a callback_url
is supplied when creating a payment - read more about webhooks on the official docs: Coinpush.io API Payment Monitoring.
Manually
You can use a payment's address label
, made when creating a payment, to inspect its statuses:
let label = 'ADDRESS_LABEL_FROM_PAYMENT_CREATION' Coinpush
Statuses indicate changes in a payment's lifespan. To discover which statuses you can check for, see: Coinpush.io API Statuses.
Approach B
This approach enables payments via one, or more, cryptocurrencies based on a fiat currency and amount. It makes use of charge tokens, which are used in conjunction with the Javascript Charge UI plugin.
Charge Tokens
let fiat = 'usd' // The fiat currency to charge in. Coinpush
Read more about charge tokens here: Coinpush.io API Charge Tokens.
Charge Monitoring
To monitor a charge payment you must inspect its statuses:
let token = 'CHARGE_TOKEN_FROM_CHARGE_CREATION' Coinpush
Read more about charge monitoring here: Coinpush.io API Charge Monitoring.
Response Status Codes
Coinpush always responds with meaningful HTTP status codes, look out for these:
Code | Description |
---|---|
200 | The request was successful. |
201 | The request was successful and a new resource was created. |
400 | The request was not validated or formatted properly. |
404 | The given input or resource was not found. |
405 | The request method was not supported. |
429 | You exceeded the given rate limit. |
500 | The API experienced an internal server error. |
503 | The API is down for maintenance. |