Pre-payment validation check

In case of exchange payment, the merchant can check a few validations before initiating a payment ex:

  1. Insufficient Balance

  2. The deposit address is not whitelisted

  3. Password is required

  4. etc

This API is NOT a core element of the payment flow. However, this helps to make a user-friendly payment solution.

The validation messages vary from exchange to exchange, but the API returns the same object with a different code that needs to handle at the merchant website.

Example:

  1. OKcoin needs the deposit address for the whitelist, so this API checks whether or not the user has already whitelisted this address. In the API response, if the key "showWhitelistElement: true" means the deposit address is not whitelisted and merchant website should display the customer error.

  2. A shopper's password is needed to withdraw the fund. If API returns a key "password: true," the shopper didn't provide the password, and the merchant's website should display a message to enter the password.

This API accepts the request payload in an encrypted format. The encryption algo is <algo_name> and encryption key is <client_secret>.

// The sample request payload that needs to encrypt
{
  "clientId": "merchantid",
  "assets": "Selected exchange currency",
  "cart": "cart array",
  "offerId": "Order_id",
  "confirmation": "true",
  "nativeAmount": "cart amount in usd"
}

// clientId: The RKFL merchant identifier
// assets: Selected exchange currency (BTC/ETH)
// cart: cart array [{},{}]
// offerId: merchant unique identifie
// confirmation: true/false, true if shopper accept term and condition
// nativeAmount: cart total amount in USD

// The key "data" should generate from the below way.
export const data = async (toEncrypt, publicKey) => {
  const buffer = Buffer.from(toEncrypt);
  const encrypted = crypto.publicEncrypt(publicKey, buffer);
  return encrypted.toString('base64');
};

POST /exchanges/payment-validate/{exchange_name}

The value of exchange_name are "coinbase/okcoin/kraken/gemini/binanceus"

Headers

NameTypeDescription

Authorization*

String

"Bearer" + shopper access token

Content-Type

String

application/json

Request Body

NameTypeDescription

data*

String

Encrypted string

{
    "ok": true,
    "result": {
        "receiverAddress": "3Jmmku8JTHP2YsqNZ3RuhZdburbdHMtSjT",
        "receiverMemo": null,
        "amount": 0,
        "currency": "BTC",
        "fee": 0.00000526,
        "password": false,
        "showWhitelistElement": false,
        "exchange": "coinbase",
        "nativeAmount": 5,
        "newRate": {
            "percentRate": 0,
            "newFiatRate": 0
        }
    }
}

Last updated