Alt 5 Pay API

Overview

Alt 5 Pay  provides a standards-based REST interface which enables application developers to interact with their Alt 5 Pay merchant account. Using the Alt 5 Pay API, clients can create depositing wallet address to accept BTC, ETH and Alt 5 Stable coin for payment, real time digital asset to fiat rates and receive notification of payments received.

Environments

The following environments are available

Environment Base URL BTC Blockchain
BTC Production https://api.alt5pay.com:5000/usr/wallet/btc/create mainnet
BTC Sandbox https://sandboxapi.alt5pay.com:5000/usr/wallet/btc/create testnet
BCH Production https://api.alt5pay.com:5000/usr/wallet/bch/create mainnet
BCH Sandbox https://sandboxapi.alt5pay.com:5000/usr/wallet/bch/create testnet
ETH Production https://api.alt5pay.com:5000/usr/wallet/eth/create mainnet
ETH  Sandbox https://sandboxapi.alt5pay.com:5000/usr/wallet/eth/create ropsten
LTC Production https://api.alt5pay.com:5000/usr/wallet/ltc/create mainnet
LTC  Sandbox https://sandboxapi.alt5pay.com:5000/usr/wallet/ltc/create testnet


Getting Started

In order to use Trade API, user will have to go through few simple steps:

  1. API key
  2. HMAC authorization header

API key

To use API, user will need to obtain API Public key and Secret Key, which are passed to API with every request. API keys can be generated in your merchant dashboard at dashboard.alt5pay.com under Settings > API Keys section.

HMAC authorization header value

Once user obtained API key, it is all set up! Now, the only thing left is to form HMAC authorization header variable. In order to form this header, user will need following variables:

var apikey = ‘public key’; // key obtained from alt5pay

var secretkey = ‘secret key’; // secret obtained from alt5pay

var timestamp = Math.floor(Date.now() / 1000); // timestamp in seconds

var nonce = Math.floor(Math.random() * Math.floor(1000000)); // random nonce integer

 

The last variable, which is needed is Parameters from body (JSON), String consists of ALL parameters from body separated by ‘&’ sign if more than one (for example: ‘ref_id=mk1231sa11&timestamp=1588364168&nonce=900288).

 

bodyString=’ref_id=mk1231sa11&timestamp=1588364168&nonce=900288’

 

If the url and/or currency variables are being passed in the body, they must be added as follows

bodyString=’ref_id=mk1231sa11&url=https://yourwebhookurl.com&timestamp=1588364168&nonce=900288&currency=USD’

Finally, user has to put all of the variables together and encode them:

parameters from url and body

var hmacDigest = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA512(bodyString, secretkey));

var authentication = btoa(apikey + ‘:’ + hmacDigest);

That’s it! User can now use variable ‘authentication’ as header to communicate with trade API.

Merchant id to be used in the header *Required

A merchant Id is required to be passed in the header.

User Merchant ID can be found in user Alt 5 Pay dashboard at dashboard.alt5pay.com or sandbox.alt5pay.com under Settings > section Account information section.

 

Receiving Payments

 

Create Payment Wallet Address

Post Create Wallet Address API

<asset> variable = btc, eth, bch

https://api.alt5pay.com:5000/usr/wallet/<asset>/create
https://sandboxapi.alt5pay.com:5000/usr/wallet/<asset>/create

Headers

 

apikey.                9c0c51ee6f3798e3aae63ea630ddd2b7265fe54f

(public key value)

merchant_id       (Merchant id in Account Information)

authentication.    (authentication value generated)

RAW JSON BODY

{  “ref_id”: “user unique reference/invoice id per client”,

“url”: “https://yourwebhookurl.com”, (optional field, this will override the webhook url set in the API key options. )

“timestamp”: 1550838976,  “nonce”: 693795,“currency”:”USD” ( options USD,CAD,EUR. If field is not included USD is used by default. )} 

Example Successful Response

{

“status”: “success”,

“data”: {

“ref_id”: “cor121121”,

“price”: 8632.59,

“address”: “moep287CANJhZoyssrigoHtkMwBiz6uhDt”,

“coin”: “BTC”,

“expires”: “2020-05-04 14:32:46.480”

}

}

 

Example Failed  Response

{

“status”: “error”,

“message”: “Access Invalid”

}

Or

{

“status”: “error”,

“message”: ” Could Not Create Address

}

Alt 5 Pay Payment Webhook Call Back Notification

Instant Payment Notifications (IPNs) are sent from Alt 5 Pay upon every confirmed status change.  IPNs are POSTed to your webhook URL specified in user Alt 5 Pay dashboard.  If the Alt 5 Pay gateway receives an HTTP/1.1 200 OK response from your server, the message is deemed to have been correctly delivered.

NOTE: This does not mean user application correctly handled the data – only that it was received successfully by user server!

If an HTTP error code is received by the gateway, Alt 5 Pay server will attempt to resend the IPN at increasing time intervals.

The amount of time between each re-post is as follows: 1 minute delay, 2 minute delay, 4 minute delay, 8 minute delay, 20  minute delay, 40  minute delay, 80 minute delay,  160 minute delay, 320 minute delay, 640 minute delay and 1,280 minute delay. The IPN system stops re-posting when:

Alt 5 Pay receives a basic HTTP “200 OK” response from your web server, or

when 1,280 minutes have passed since the initial post.

Note: This functionality applies to both Sandbox and Live accounts.
 

Webhook URL (IPN) Response

Headers

signature              CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA512(Body, secretkey));

Body

{“ref_id”:”wm_123323″,

“price”:8550.26,

“amount”:0.0006,

“total”:5.13,

“date_time”:”1588354319000″,

“transaction_id”:”c3c2920e4705cc37c57d0937576d6346c27ca81f2b9e507fd47a1de113b7bba9″,

“coin”:”BTC”,

“network”:”testnet”,

“currency”:”USD”

}

Get Transaction Status

https://api.alt5pay.com:5000/usr/wallet/transactions
https://sandboxapi.alt5pay.com:5000/usr/wallet/transactions

Headers

 

apikey.                9c0c51ee6f3798e3aae63ea630ddd2b7265fe54f

(public key value)

merchant_id       (Merchant id in Account Information)

authentication.    (authentication value generated)

RAW JSON BODY

{“address”: “bchtest:qpggts6de95hnutg8wrxx55mh9z2dnxp2v64tuqn73”,

“timestamp”: 1550838976,  “nonce”: 693795}

Example Successful Response

{

“status”: “success”,

“data”: {

“date_time”: “2020-07-31T22:10:21.000Z”,

“address”: “bchtest:qpggts6de95hnutg8wrxx55mh9z2dnxp2v64tuqn73”,

“status”: “Paid”, (Paid,Pending)

“payment_amount”: 0.01655245,

“total_payment”: 6.54,

“txid”: “0bd4d3c2ab491649bc5c7328aba8d46b2c2c856ca5cd8261d489a7e01c2a5f12”,

“price”: 395.23,

“currency”: “CAD”,

“coin”: “BCH”

}

}