API Guide

Overview

The B2BinPay API is organized in accordance with JSON API paradigm. For a better understanding of the paradigm principles, read the JSON API Specification.

We use conventional HTTP response codes, OAuth 2.0 protocol for authentication, and HMAC-SHA256 algorithm for encryption.

Via the API you can get access to all the main entities of the payment system:

  • Wallets — read-only

  • Currencies — read-only

  • Transfers — read-only

  • Rates — read-only

  • Deposits and Invoices — read/write access

  • Payouts — read/write access

Filters by object parameters can be applied to any GET-method according to the JSON API Specification.

We also provide flexible options for callback — an asynchronous notification about changing the status of a deposit/payout. To receive a callback, specify a callback URL when sending a Create deposit, Create invoice or Create payout request. When a transaction receives the required number of confirmations, we will send a callback via HTTP POST request to this URL. If you also want to be notified when the number of confirmations received for a transaction doesn’t reach a specific threshold or exceeds it, indicate the required number of confirmations in the request.

All methods are private. All requests except for Obtain token and Refresh token should contain HTTP header: Authorization: Bearer <Access Token>.

According to JSON API Specification, all requests should contain HTTP header: Content-Type: application/vnd.api+json.

The number of requests to the endpoint without prior authentication is limited to 70 per 1 minute.

To check the network availability of the system, use the /ping endpoint without authorization headers.

Required fields are marked with *.

Base URL

Code

Production

Sandbox

[base]

https://api.b2binpay.com/

https://api-sandbox.b2binpay.com/

Authentication

Obtain token

#enterprise #merchant

Note

API credentials were sent to your e-mail after registration. You can regenerate them anytime in Control panel > API Access.

Request

login* string

Your API key.

password* string

Your API secret.

POST[base]/token/

$ curl --request POST \
       --url https://api.b2binpay.com/token/ \
       --header 'content-type: application/vnd.api+json' \
       --data '{
         "data": {
           "type": "auth-token",
           "attributes": {
             "login": "<Change to your API key>",
             "password": "<Change to your secret>"
           }
         }
       }'
import requests

url = 'https://api.b2binpay.com/token/'

headers = {
    'content-type': 'application/vnd.api+json',
}

data = {
    'data': {
        'type': 'auth-token',
        'attributes': {
            'login': '<Change to your login>',
            'password': '<Change to your secret>',
        },
    },
}

requests.post(url, headers=headers, json=data)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->post('https://api.b2binpay.com/token/', [
        'json' => [
            'data' => [
                'type' => 'auth-token',
                'attributes' => [
                    'login' => '<Change to your login>',
                    'password' => '<Change to your secret>',
                ],
            ],
        ],
        'headers' => [
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

access string

Your access token that has an expiry time of about a minute and after expiration should be refreshed.

refresh string

A long-living token which is used for obtaining new access tokens.

access_expired_at string

Expiration time for access token as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

refresh_expired_at string

Expiration time for refresh token as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

is_2fa_confirmed boolean

If true, 2FA is enabled.

meta.time string

Time of request receiving as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

meta.sign string

HMAC signature for a response payload authentication. To verify that the refresh token was sent by us, generate an HMAC signature using the sha256 as algorithm: sha256 hash of the concatenation of your login and password as a key, and the concatenation of meta.time and refresh token fields as a message. Refer to Auth verification for sign verification example.

RESPONSE BODY EXAMPLE
{
  "data": {
    "type": "auth-token",
    "id": "0",
    "attributes": {
      "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
      "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
      "access_expired_at": "2020-12-29T05:42:11.925654Z",
      "refresh_expired_at": "2020-12-29T11:27:11.925654Z",
      "is_2fa_confirmed": false
    }
  },
  "meta": {
    "time": "2020-12-29T05:27:11.925654Z",
    "sign": "bcd6519ce27fed2ce9efe49cd09b387f050c0122c962c18ff474132bf1e88e9a"
  }
}

HTTP status codes

200 Success.

400 Bad Request. No active account found with the given credentials.

429 Too Many Requests. More than 15 requests were sent in 60 seconds, the request was throttled.


Refresh token

#enterprise #merchant

Important

Once you receive a new key pair using your refresh token, the previous refresh token can no longer be used. A refresh token that is found to be invalid while not being expired must be rendered suspicious.

Request

refresh* string

Your refresh token from the Obtain token response.

POST[base]/token/refresh/

$ curl --request POST \
       --url https://api.b2binpay.com/token/refresh/ \
       --header 'content-type: application/vnd.api+json' \
       --data '{
           "data": {
             "type": "auth-token",
             "attributes": {
               "refresh": "<Change to your refresh token>"
             }
           }
         }'
import requests

url = 'https://api.b2binpay.com/token/refresh/'

headers = {
    'content-type': 'application/vnd.api+json',
}

data = {
    'data': {
        'type': 'auth-token',
        'attributes': {
            'refresh': '<Change to your refresh token>',
        },
    },
}

requests.post(url, headers=headers, json=data)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->post('https://api.b2binpay.com/token/refresh/', [
        'json' => [
            'data' => [
                'type' => 'auth-token',
                'attributes' => [
                    'refresh' => '<Change to your refresh token>',
                ],
            ],
        ],
        'headers' => [
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

Response body is the same as for Obtain token request, but without meta fields.

RESPONSE BODY EXAMPLE
{
  "data": {
    "type": "auth-token",
    "id": "0",
    "attributes": {
      "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
      "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
      "access_expired_at": "2020-12-29T05:42:11.925654Z",
      "refresh_expired_at": "2020-12-29T11:27:11.925654Z",
      "is_2fa_confirmed": false
    }
  }
}

HTTP status codes

200 Success.

401 Refresh token is invalid or expired.


Wallet Methods

Wallet object

#enterprise #merchant

label string

The wallet name for convenient searching.

status number

Current status of the wallet:

  • 1 — Not active. The wallet is available in the read only mode.

  • 2 — In progress. The wallet is now being registered in the system and currently unavailable.

  • 3 — Active. The wallet has been activated and can be used to create deposits/invoices and payouts.

created_at string

Time of the wallet creation as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

balance_confirmed string

The available balance that can currently be used for payouts.

balance_pending string

The locked balance, the sum of all incoming and outgoing transfers that have not yet received confirmation: positive in case of deposit/invoice and negative in case of payout. This balance cannot currently be used for transfers.

balance_unusable string

The amount of funds that cannot be used. They are not available, although some part of them can be unblocked. The reason for temporary blocking may be a suspicious operation that does not comply with AML/KYT rules. If transfer is failed or cancelled, its amount will be added to the unusable balance.

minimal_transfer_amount string

The minimum amount of crediting to the wallet in the wallet currency. If the amount of the incoming transfer is less than the specified minimal transfer amount, the transfer will be canceled.

destination object

The field is available for Enterprise users only. The field contains two string fields: address_type — refer to Deposit and invoice address types for supported values, and address — public wallet address, that can be used to directly top up wallet balance.

currency object

The wallet currency. The field includes currency id (refer to Currency codes for supported values).

parent object

The field is available for Enterprise users only. Parent wallet applicable for token wallets only; for coin wallets returns null. Contains parent wallet id.

WALLET OBJECT
{
  "data": {
    "type": "wallet",
    "id": "20",
    "attributes": {
      "status": 3,
      "created_at": "2020-11-06T06:03:44.301815Z",
      "balance_confirmed": "0.00000000",
      "balance_pending": "0.00000000",
      "balance_unusable": "0.23221548",
      "minimal_transfer_amount": "0.100000000000000000",
      "destination": {
        "address_type": "p2sh-segwit",
        "address": "2N3Ac2cZzRVoqfJGu1bFaAebq3izTgr1WLv"
      }
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "2005"
        }
      },
      "parent": {
        "data": {
          "type": "wallet",
          "id": "14"
        }
      }
    }
  }
}

Get wallet

#enterprise #merchant

Request

id string

The wallet identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/wallet/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/wallet/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/wallet/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/wallet/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a wallet object or an array of objects (if id was not specified) is returned.

The wallets list is paginated and default page size is 10.

HTTP status codes

200 Success.

400 Bad request. You have no permission to view the wallet with given id.

404 The wallet with given id was not found.


Currency Methods

Currency object

#enterprise #merchant

iso number

The currency numeric identifier. It is identical to id.

name string

The currency full name: for example, Bitcoin.

alpha string

Currency alphabetic identifier: for example, BTC.

exp number

Currency precision (the number of digits after the decimal separator).

confirmation_blocks number

Default number of blocks needed to send a callback.

minimal_transfer_amount string

The minimum amount of crediting to the wallet in the wallet currency. If the amount of the incoming transfer is less than the specified minimal transfer amount, the transfer will be cancelled.

block_delay number

An estimated block mining time, in seconds.

parent object

Parent currency applicable for tokens only; for coins returns null. Contains parent currency id and represents a blockchain relating to the parent currency.

alias string

Ticker or alias. Used for identifying similar currencies based on different blockchains.

CURRENCY OBJECT
{
  "type": "currency",
  "id": "2015",
  "attributes": {
    "iso": 2015,
    "name": "TetherUS",
    "alpha": "USDT-ETH",
    "alias": "USDT",
    "exp": 6,
    "confirmation_blocks": 3,
    "minimal_transfer_amount": "15.000000",
    "block_delay": 0
  },
  "relationships": {
    "parent": {
      "data": {
        "type": "currency",
        "id": "1002"
      }
    }
  }
}

Get currency

#enterprise #merchant

Request

id string

The currency identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/currency/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/currency/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/currency/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/currency/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a currency object or an array of objects (if id was not specified) is returned.

HTTP status codes

200 Success.

404 Currency with given id not found.


Transfer Methods

Transfer object

#enterprise #merchant

confirmations number

The number of blockchain confirmations received.

op_id number

Identifier of the associated operation.

op_type number

Type of the associated operation:

  • 1 — a deposit/invoice

  • 2 — a payout

  • 5 — an incoming transfer due to exchange execution

  • 9 — the writing off costs associated with sending tokens; the amount of such transfer includes blockchain fee for withdrawal of tokens

  • 14 — the direct deposit to the wallet address

  • 16 — other wallet fees charging

  • 17 — an outgoing transfer due to exchange execution

  • 19 — a non-withdrawable activation transfer for Ripple, Stellar, Binance Coin

risk_status number

The status of the AML check:

  • 1 — transfer is checked and marked as green

  • 2 — transfer is in the queue for checking

  • 3 — transfer is checked and marked as red

  • 4 — transfers of this type are unavailable for the check

risk number

The percent of the AML risk for the transfer. Possible value range is from 0 to 100. The field can have null value if the AML check was not performed.

status number

Transfer status:

  • -3 — the transfer is cancelled due to security reasons or a small transaction amount

  • -2 — the transfer is temporarily blocked due to security reasons

  • -1 — the tansfer has failed in the blockchain

  • 0 — the transfer is created (pending in queue for processing)

  • 1 — the transfer is unconfirmed (not enough confirmations or AML check is still being performed)

  • 2 — the transfer is confirmed

amount string

Useful part of the transfer amount. It is calculated as the transfer amount minus the blockchain commission. For the deposit/invoice transfers, this field reflects the amount received.

amount_target number

The field is applicable for Merchant users only. The transfer amount, in the wallet currency.

commission string

Processing fee amount.

commission_target number

The field is applicable for Merchant users only. Processing fee amount of the commission, in the wallet currency.

txid string

The address for the received payment.

fee string

The blockchain fee. For deposits/invoices the value is always 0.

user_message string

Notes or errors descriptions.

created_at string

The time of the transfer creation as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

updated_at string

The time of the transfer update as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

currency object

The transaction currency. Contains currency id (refer to Currency codes for supported values).

wallet object

The wallet with which the transaction is associated. Contains wallet id and a link to the wallet.

parent object

Applicable mainly for tokens. Contains a link to the parent transfer, if the current transfer depends on the parent one. In other cases returns null.

TRANSFER OBJECT
{
  "data": {
    "type": "transfer",
    "id": "82",
    "attributes": {
      "confirmations": 487,
      "op_id": 2,
      "op_type": 18,
      "risk_status": 1,
      "risk": 15,
      "amount": "0.00001500",
      "commission": "0.00000000",
      "fee": "0.00000329",
      "txid": "4642e3ed5f78b9b9f08a6ca2799e0b9a840a0f4eae3ca4bffebae",
      "status": 2,
      "user_message": null,
      "created_at": "2020-11-06T06:25:37.151758Z",
      "updated_at": "2020-11-06T08:17:16.453885Z"
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      },
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "14"
        }
      },
      "parent": {
        "data": null
      }
    }
  }
}

Get transfer

#enterprise #merchant

Request

id string

The transfer identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/transfer/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/transfer/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/transfer/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/transfer/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a transfer object or an array of objects (if id was not specified) is returned.

HTTP status codes

200 Success.

400 Bad request.

404 Transfer with given id not found.

Transfer filtering

#enterprise #merchant

For quick search through lists, filtering can be used. The filtering is performed by means of adding GET parameters to the query string. You can filter by the object fields name. Note that some fields cannot be used as filter criteria.

Request

No parameters

GET[base]/transfer/

$ curl --request GET \
       --url ‘http://0.0.0.0:80/transfer/?%5Bop_type%5D=2&filter%5Bop_id%5D=100\
       --header ‘Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjM5MDAzODg5LCJqdGkiOiJmYzM2ZGIyMWU3NmM0ODk4OWI1ZjYwNDlkNmZmYjQ2YSIsInVzZXJfaWQiOjR9.axybuLc5qVBiyTw12O1kap1mzcIeB-s4GVnYX_NDGDI’

HTTP status codes

200 Success.

400 Bad request.


Rates Methods

Rate object

#enterprise #merchant

left string

Base currency.

right string

Quote currency.

bid string

Bid price.

ask string

Ask price.

exp number

Currency precision (number of digits after the decimal separator) for the bid and ask fields.

created_at string

The time of the rate creation.

expired_at string

The time when the rate will be replaced with a more relevant one.

RATE OBJECT
{
  "data": {
    "type": "rate",
    "id": "0",
    "attributes": {
      "left": "XRP",
      "right": "USD",
      "bid": "0.55",
      "ask": "0.57",
      "exp": 2,
      "expired_at": "2021-02-22T14:12:54.954810Z",
      "created_at": "2021-02-22T14:07:54.954810Z"
    }
  }
}

Get rates

#enterprise #merchant

Request

Rates can be filtered by the the left and right parameter according to the JSON API Specification. For example, the response body will only contain rates with BTC base currency: /rates?filter[left]=BTC

GET[base]/rates/

$ curl --request GET \
       --url https://api.b2binpay.com/rates/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/rates/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/rates/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, an array of rate objects is returned.

HTTP status codes

200 Success.

400 Bad request.


Deposit Methods

Deposit object

#enterprise

target_paid string

The sum of transaction amounts. After the creation equals to 0. This is a total amount paid by a user for this deposit.

payment_page string

URL of the payment page provided to payers; the page contains address, tag, QR-code and registered incoming transfers.

address_type string

Address type. Refer to Deposit and invoice address types for supported values.

tracking_id string or number

Client-provided identifier of the payment in the external system.

confirmations_needed number

Client-provided number of confirmations for sending an additional callback.

callback_url string

URL for callback notifications.

address string

Address for the received payment.

destination object

All possible options to specify the address of the deposit: an object if there is only one possible option, array of objects if there are several options. Each object contains three string fields: address — actual address, address_type — type of the address, tag — destination tag (if required), used in conjunction with address tag_type — type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

assets object

Amounts of incoming transfers in different currencies. The information is relevant for tokens, if both tokens and coins can be sent to a single address. In this case, the funds are credited not only to the wallet from the wallet field, but also to other wallets in other currencies. The alpha code of the currency is used as a key. Aggregated amounts are values.

label string

The deposit name for convenient searching.

currency object

The wallet currency. Contains currency id (refer to Currency codes for supported values).

wallet object

The wallet with which the transaction is associated. Contains wallet id and a link to the wallet.

DEPOSIT OBJECT
{
  "data": {
    "type": "deposit",
    "id": "3",
    "attributes": {
      "target_paid": "450.00",
      "payment_page": "https://pay.b2binpay.com/#/d/4ba00d23-21e8-4608-b4aa-804ae5474705",
      "address_type": "p2sh-segwit",
      "tracking_id": "2244",
      "confirmations_needed": null,
      "callback_url": "https://my.client.url/cb/",
      "address": "2NBYrj5JbiswTH5JXrxZ5Z8esujcmfPgaYR",
      "destination": {
        "address_type": "p2sh-segwit",
        "address": "2NBYrj5JbiswTH5JXrxZ5Z8esujcmfPgaYR"
      },
      "assets": {
        "USDT": {
          "wallet_id": 7,
          "target_paid": "450.00",
          "target_commission": "2.25",
          "enrolled": "447.75",
          "target_paid_pending": "0.00",
          "blockchain_balance": "0.00"
        },
        "BTC": {
          "wallet_id": 3,
          "target_paid": "0.10000000",
          "target_commission": "0.00050000",
          "enrolled": "0.09950000",
          "target_paid_pending": "0.00000000",
          "blockchain_balance": "0.10000000"
        }
      }
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "2005"
        }
      },
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "7"
        }
      }
    }
  }
}

Get deposit

enterprise

Request

id string

The deposit identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/deposit/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/deposit/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/deposit/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/deposit/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a deposit object or an array of objects (if id was not specified) is returned.

HTTP status codes

200 Success.

400 Bad request. You have no permission to view the deposit with given id.

404 Deposit with given id not found.


Create deposit

#enterprise

Request

wallet* object

The identifier of the wallet to which the payments will be deposited.

label string

The deposit name for convenient searching.

callback_url string

URL to send callback notifications. Specify this value to receive a callback when a new transaction occurs. Refer to Deposit callback for more details.

confirmations_needed number

The required number of confirmations to trigger an additional callback. Specify this value to receive an additional callback before or after the transaction is confirmed. Refer to Deposit callback for more details.

tracking_id string or number

The deposit identifier in your system. This ID is used in callbacks.

address_type string

Address type, depends on a currency. Refer to Deposit and invoice address types for supported values.

POST[base]/deposit/

$ curl --request POST \
       --url https://api.b2binpay.com/deposit/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json' \
       --data '{
           "data": {
             "type": "deposit",
             "attributes": {
               "label": "My new deposit",
               "tracking_id": "d-abcd",
               "confirmations_needed": 2,
               "callback_url": "https://my.client.com/cb/"
             },
             "relationships": {
               "wallet": {
                 "data": {
                   "type": "wallet",
                   "id": "1"
                 }
               }
             }
           }
         }'
import requests

url = 'https://api.b2binpay.com/deposit/'

headers = {
    'authorization': '<Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

data = {
    'data': {
        'type': 'deposit',
        'attributes': {
            'label': 'My new deposit',
            'tracking_id': 'd-abcd',
            'confirmations_needed': 2,
            'callback_url': 'https://my.client.com/cb/',
        },
        'relationships': {
            'wallet': {
                'data': {
                    'type': 'wallet',
                    'id': '1',
                },
            },
        },
    },
}

requests.post(url, headers=headers, json=data)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->post('https://api.b2binpay.com/deposit/', [
        'json' => [
            'data' => [
                'type' => 'deposit',
                'attributes' => [
                    'label' => 'My new deposit',
                    'tracking_id' => 'd-abcd',
                    'confirmations_needed' => 2,
                    'callback_url' => 'https://my.client.com/cb/',
                ],
                'relationships' => [
                    'wallet' => [
                        'data' => [
                            'type' => 'wallet',
                            'id' => '1',
                        ],
                    ],
                ],
            ],
        ],
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a newly created deposit object is returned, containing an address that your payers can use to send funds.

HTTP status codes

201 Success.

400 Bad request: invalid request parameters or required field value was not sent.


Deposit callback

#enterprise

Upon receiving a required number of confirmations of a new deposit transaction, a callback will be sent to your server if the body of the deposit contains a valid callback URL. You can use it to make changes in your system and notify your payers.

The callback is sent by a POST request, which contains useful JSON payload. After processing the payload, you should send back an HTTP code 200 response without a body. If your server is temporarily unavailable or the status of the response is different from 200, we will resend the callback several times with the increasing delay time. The number of resendings is limited. If the manual resending is required, you can do it via the Events.

A callback consists of two parts: the deposit itself (data) and the transaction received for this deposit (included).

address string

The identifier of the wallet to which the payment is deposited.

created_at string

The time of the transfer update as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

tracking_id string or number

The deposit identifier in your system.

target_paid string

If an additional callback is required before or after the transaction is confirmed, set the number of confirmations that will trigger a callback sending.

destination object

All possible options to specify the address of the deposit: an object if there is only one possible option, array of objects if there are several options. Each object contains three string fields: address — actual address, address_type — type of the address, tag — destination tag (if required), used in conjunction with address tag_type — type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

currency object

The transaction currency. Contains currency id (refer to Currency codes for supported values).

wallet object

The identifier of the wallet to which the payments will be deposited.

transfer object

The transaction identifier.

meta.time string

The time of the callback sending as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

meta.sign string

HMAC signature for a callback authentication. To verify that the callback was sent by us, generate an HMAC signature using sha256 as algorithm: sha256 hash of the concatenation of your login and password as a key, and the concatenation of the transfer.status, transfer.amount, deposit.tracking_id, meta.time fields as message. Refer to Callback verification for a sign verification example.

CALLBACK BODY
{
  "data": {
    "type": "deposit",
    "id": "7",
    "attributes": {
      "address": "mrPu2kxsYYLMaWWGWGddG2ty3EYTotrmuS",
      "created_at": "2021-09-30T10:52:55.843096Z",
      "tracking_id": "12",
      "target_paid": "0.00200000",
      "destination": {
        "address_type": "legacy",
        "address": "mrPu2kxsYYLMaWWGWGddG2ty3EYTotrmuS"
      }
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      },
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "19"
        }
      },
      "transfer": {
        "data": {
          "type": "transfer",
          "id": "144"
        }
      }
    }
  },
  "included": [
    {
      "type": "currency",
      "id": "1000",
      "attributes": {
        "iso": 1000,
        "name": "Bitcoin",
        "alpha": "BTC",
        "alias": null,
        "exp": 8,
        "confirmation_blocks": 3,
        "minimal_transfer_amount": "0.00000546",
        "block_delay": 3600
      }
    },
    {
      "type": "transfer",
      "id": "144",
      "attributes": {
        "confirmations": 4,
        "risk": 0,
        "risk_status": 4,
        "op_id": 7,
        "op_type": 1,
        "amount": "0.00200000",
        "commission": "0.00000800",
        "fee": "0.00000000",
        "txid": "add14bba24526b23a79f3df2fa945c8c06cf5893e1b5b6d1d302e05c9a41014b",
        "status": 2,
        "user_message": null,
        "created_at": "2021-09-30T12:34:34.087418Z",
        "updated_at": "2021-09-30T12:34:52.455066Z"
      },
      "relationships": {
        "currency": {
          "data": {
            "type": "currency",
            "id": "1000"
          }
        }
      }
    }
  ],
  "meta": {
    "time": "2021-09-30T12:34:52.799609+00:00",
    "sign": "bc6cc117b00a5c0fa87ddda034c9efdca41b726ff82f6da9e60cffd1d9ffa5cf"
  }
}

Invoice Methods

Invoice object

#merchant

payment_page string

URL of the payment page provided to payers; the page contains address, tag, QR-code and registered incoming transfers.

address_type string

Address type. Refer to Deposit and invoice address types for supported values.

tracking_id string or number

Client-provided identifier of the payment in the external system.

confirmations_needed number

Client-provided number of confirmations for sending an additional callback.

callback_url string

URL for callback notifications.

address string

Address for received payment.

destination object

All possible options to specify the address of the invoice: an object if there is only one possible option, array of objects if there are several options. Each object contains three string fields: address — actual address, address_type — type of the address, tag — destination tag (if required), used in conjunction with address tag_type — type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

assets object

Amounts of incoming transfers in different currencies. The information is relevant for tokens, if both tokens and coins can be sent to a single address. In this case, the funds are credited not only to the wallet from the wallet field, but also to other wallets in other currencies. The alpha code of the currency is used as a key. Aggregated amounts are values.

label string

The invoice name for convenient searching.

currency object

The invoice payment currency. Contains currency id (refer to Currency codes for supported values).

wallet object

The wallet with which the transaction is associated. Contains wallet id and link to the wallet.

INVOICE OBJECT
{
  "data": {
    "type": "deposit",
    "id": "205",
    "attributes": {
      "target_paid": "0.00",
      "payment_page": "https://pay.b2binpay.com/#/d/62e51de3-faaa-4701-b3e4-c11f207ca508",
      "address": "2NFvFBzuC7pkro5yr855JcU91KZkp4UAt6f",
      "destination": {
        "address_type": "p2sh-segwit",
        "address": "2NFvFBzuC7pkro5yr855JcU91KZkp4UAt6f"
      },
      "label": "test label",
      "tracking_id": "U-988",
      "confirmations_needed": 1,
      "callback_url": "https://my.client.url/cb/",
      "rate_requested": "9900.00000000",
      "rate_expired_at": "2021-09-17T07:35:38.352821Z",
      "invoice_updated_at": "2021-09-17T07:35:07.831725Z"
    },
    "relationships": {
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "65"
        }
      },
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      }
    }
  }
}

Get invoice

#merchant

Request

id string

The invoice identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/deposit/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/deposit/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'

Response

In case of a successful response, an invoice object or an array of objects (if id was not specified) is returned.

HTTP status codes

200 Success.

400 Bad request. You have no permission to view the invoice with given id.

404 Invoice with given id not found.


Create invoice

#merchant

Request

wallet* object

The identifier of the wallet to which the payments will be credited.

label string

The invoice name for convenient searching.

callback_url string

URL to send callback notifications. Specify this value to receive a callback when a new transaction occurs. Refer to Invoice callback for more details.

confirmations_needed number

Required number of confirmations to trigger an additional callback. Specify this value to receive an additional callback before or after the transaction is confirmed. Refer to Invoice callback for more details.

tracking_id string or number

The invoice identifier in your system. This ID is used in callbacks.

address_type string

Address type, depends on a currency. Refer to Deposit and invoice address types for supported values.

currency object

The invoice payment currency. If the field is blank, the invoice payment currency will be selected by a payer manually.

POST[base]/deposit/

$ curl --request POST \
       --url https://api.b2binpay.com/deposit/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json' \
       --data '{
            "data": {
                "type": "deposit",
                "attributes": {
                    "label": "test label",
                    "tracking_id": "U-988",
                    "confirmations_needed": 1,
                    "callback_url": "https://my.client.url/cb/"
                },
                "relationships": {
                    "currency": {
                       "data": {
                         "type": "currency",
                         "id": "1000"
                        }
                    },
                    "wallet": {
                        "data": {
                            "type": "wallet",
                            "id": "65"
                        }
                    }
                }  
            }
        }'

Response

In case of a successful response, a newly created invoice object is returned, containing an address that your payers can use to send funds.

HTTP status codes

201 Success.

400 Bad request: invalid request parameters or required field value was not sent.


Invoice callback

#merchant

Upon receiving a required number of confirmations of a new transaction, a callback will be sent to your server if the body of the invoice contains a valid callback URL. You can use it to make changes in your system and notify your payers.

The callback is sent by a POST request, which contains useful JSON payload. After processing the payload, you should respond with an HTTP code 200 without a body. If your server is temporarily unavailable or the status of the response is different from 200, we will resend the callback several times with the increasing delay time. The number of resendings is limited. If the manual resending is required, you can do it via the Events.

A callback consist of two parts: the invoice itself (data) and the transaction received for this invoice (included).

address string

The identifier of the wallet to which the payment is credited.

created_at string

The time of the transfer update as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

tracking_id string or number

The invoice identifier in your system.

destination object

All possible options to specify the address of the invoice: an object if there is only one possible option, array of objects if there are several options. Each object contains three string fields: address — actual address, address_type — type of the address, tag — destination tag (if required), used in conjunction with address tag_type — type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

currency object

The transaction currency. Contains currency id (refer to Currency codes for supported values).

wallet object

The identifier of the wallet to which the payments will be credited.

transfer object

The transaction identifier.

meta.time string

The time of the callback sending as per ISO 8601 with μs precision and timezone included: YYYY-MM-DDThh:mm:ss[.SSSSSS]±hh:mm.

meta.sign string

HMAC signature for a callback authentication. To verify that the callback was sent by us, generate an HMAC signature using sha256 as algorithm: sha256 hash of the concatenation of your login and password as a key, and the concatenation of the transfer.status, transfer.amount, deposit.tracking_id, meta.time fields as a message. Refer to Callback verification for a sign verification example.

CALLBACK BODY
{
  "data": {
    "type": "deposit",
    "id": "8",
    "attributes": {
      "address": "2N5i8UWkduQx4Mb4YVsvJnX6deimtSFjcVH",
      "created_at": "2021-09-30T13:02:56.592398Z",
      "tracking_id": "u-998",
      "target_paid": "19.80",
      "source_amount_requested": "0.10101011",
      "target_amount_requested": "1000.00",
      "status": 2,
      "time_limit": null,
      "inaccuracy": null,
      "destination": {
        "address_type": "p2sh-segwit",
        "address": "2N5i8UWkduQx4Mb4YVsvJnX6deimtSFjcVH"
      }
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      },
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "2"
        }
      },
      "transfer": {
        "data": {
          "type": "transfer",
          "id": "147"
        }
      }
    }
  },
  "included": [
    {
      "type": "currency",
      "id": "1000",
      "attributes": {
        "iso": 1000,
        "name": "Bitcoin",
        "alpha": "BTC",
        "alias": null,
        "exp": 8,
        "confirmation_blocks": 3,
        "minimal_transfer_amount": "0.00000546",
        "block_delay": 3600
      }
    },
    {
      "type": "transfer",
      "id": "147",
      "attributes": {
        "confirmations": 4,
        "risk": 0,
        "risk_status": 4,
        "op_id": 8,
        "op_type": 1,
        "amount": "0.00200000",
        "amount_target": "19.80000000",
        "rate_target": "9900.00000000",
        "commission": "0.00000800",
        "commission_target": "0.090000000000000000",
        "fee": "0.00000000",
        "txid": "bf9b34508a24fc8d16b7c831a2b056e31bda1e8d27604208d59ad97de565efaf",
        "status": 2,
        "user_message": null,
        "created_at": "2021-09-30T13:03:11.894801Z",
        "updated_at": "2021-09-30T13:03:42.817540Z"
      },
      "relationships": {
        "currency": {
          "data": {
            "type": "currency",
            "id": "1000"
          }
        }
      }
    }
  ],
  "meta": {
    "time": "2021-09-30T13:03:43.060561+00:00",
    "sign": "6146ac69e88ea1ddb77e387024d1fa775837731e49d64a9f2b9f3c7542fe9b00"
  }
}

Payout Methods

Payout object

#enterprise #merchant

amount string

Exact amount of the payout, in the wallet currency.

exp number

Currency precision (number of digits after the decimal separator).

address string

The blockchain address of the receiver wallet. If the payout for XRP is made to an x-address, entering a tag in the tag field is not necessary. If such a payout is made to a normal address, a user should enter the destination account address in combination with a destination tag.

tag_type string

Type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

tag string

Destination tag for XRP, XLM, BNB.

destination object

All possible options to specify the receiver address; contains three string fields: address — actual address, address_type — type of the address, tag — destination tag (if required) for XRP, XLM, BNB.

tracking_id string or number

The identifier of the payment in the external system.

confirmations_needed number

Client-provided number of confirmations needed for sending an additional callback.

fee_amount string

The blockchain fee amount.

is_fee_included boolean

If true, the fee is included in the payment amount, the remaining part is credited to the receiver’s account. If false, the fee is additionally debited from the wallet. For XRP, BNB, XLM, ETH and token currencies, fee cannot be included in the amount.

status number

If a payout should be approved by the wallet owner, the following values are posiible:

  • 1 — waiting for the approval

  • 2 — approved

callback_url string

URL for callback notifications.

currency object

For Enterprise users: the wallet currency. Contains currency id (refer to Currency codes for supported values). For Merchant users: the invoice payment currency.

wallet object

The wallet with which the transaction is associated. Contains the wallet id.

PAYOUT OBJECT
{
  "data": {
    "type": "payout",
    "id": "21",
    "attributes": {
      "amount": "0.00000010",
      "exp": 8,
      "address": "2N3Ac2cZzRVoqfJGu1bFaAebq3izTgr1WLv",
      "tag_type": null,
      "tag": null,
      "destination": {
        "address_type": "legacy",
        "address": "2N3Ac2cZzRVoqfJGu1bFaAebq3izTgr1WLv"
      },
      "tracking_id": null,
      "confirmations_needed": null,
      "fee_amount": "0.00000329",
      "is_fee_included": false,
      "status": 2,
      "callback_url": null
    },
    "relationships": {
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      },
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "13"
        }
      }
    },
    "links": {
      "self": "https://api.b2binpay.com/payout/21"
    }
  }
}

Get payout

#enterprise #merchant

Request

id string

The payout identifier.

Filtering by any object parameters can be applied according to the JSON API Specification.

GET[base]/payout/{id}

$ curl --request GET \
       --url https://api.b2binpay.com/payout/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json'
import requests

url = 'https://api.b2binpay.com/payout/'

headers = {
    'authorization': '<Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->get('https://api.b2binpay.com/payout/', [
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a payout object or an array of objects (if id was not specified) is returned.

HTTP status codes

200 Success.

400 Bad request. You have no permission to view the payout with given id.

404 Payout with given id not found.


Create payout

#enterprise #merchant

Note

For security reasons, an additional HTTP header with a unique idempotency key must be sent in the request. The key is a UUID4 string with hyphens: for example, 2dbcb513-bd35-404f-9709-e34878def180. Refer to UUID tools for recommended programming packages and libraries that you can use to generate UUID4.

Request

wallet* object

The identifier of the payment wallet.

label string

The payout name for convenient searching.

callback_url string

URL to send callback notifications.

confirmations_needed number

If an additional callback is required before or after the transaction is confirmed, set the number of confirmations that will trigger a callback sending.

tracking_id string or number

The payout identifier in the external system which is used in callbacks.

address_type string

Address type, depends on a currency. Refer to Deposit and invoice address types for supported values.

address string

The wallet address to which the funds are sent.

amount string

The amount of the outgoing transfer.

currency object

The field is available for Merchant users only and is required. If the field is blank, the invoice payment currency will be selected by a payer manually.

tag string

Destination tag for XRP, XLM, BNB.

tag_type string

Type of the tag or memo, applicable for XLM. Possible values:

  • 1 — a 64-bit unsigned integer

  • 2 — a string up to 28-bytes long

POST[base]/payout/

$ curl --request POST \
       --url https://api.b2binpay.com/payout/ \
       --header 'authorization: Bearer eyJ0eXAiOiJKV1QiLC...' \
       --header 'content-type: application/vnd.api+json' \
       --header 'idempotency-key: b6891f5b-d16f-4ba9-a1c4-9828be64a492' \
       --data '{
         "data": {
             "type": "payout",
             "attributes": {
                 "amount": "0.05",
                 "address": "bcrt1q92k5z02dyrjahm4hput42nps3t7ryxzzz0vl76",
                 "fee_amount": "0.00000550",
                 "tracking_id": "f12",
                 "confirmations_needed": 2,
                 "callback_url": "https://my.client.com/cb/"
             },
             "relationships": {
                 "wallet": {
       	             "data": {
                         "type": "wallet",
                         "id": "1"
                     }
                 },
                 "currency": {
                     "data": {
                         "type": "currency",
                         "id": "1000"
                     }
                 }
             }
          }
      }'
import requests

from uuid import uuid4

url = 'https://api.b2binpay.com/payout/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
    'idempotency-key': str(uuid4()),
}

data = {
    'data': {
        'type': 'payout',
        'attributes': {
            'amount': '0.05',
            'address': 'bcrt1q92k5z02dyrjahm4hput42nps3t7ryxzzz0vl76',
            'fee_amount': '0.00000550',
            'tracking_id': 'f12',
            'confirmations_needed': 2,
            'callback_url': 'https://my.client.com/cb/',
        },
        'relationships': {
            'wallet': {
                'data': {
                    'type': 'wallet',
                    'id': '1',
                },
            },
            'currency': {
                'data': {
                    'type': 'currency',
                    'id': '1000',
                },
            },
        },
    },
}

requests.post(url, headers=headers, json=data)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->post('https://api.b2binpay.com/payout/', [
        'json' => [
            'data' => [
                'type' => 'payout',
                'attributes' => [
                    'tracking_id' => 'f12',
                    'confirmations_needed' => 2,
                    'callback_url' => 'https://my.client.com/cb/',
                    'amount' => '0.05',
                    'address' => 'bcrt1q92k5z02dyrjahm4hput42nps3t7ryxzzz0vl76',
                    'fee_amount' => '0.00000550',
                ],
                'relationships' => [
                    'wallet' => [
                        'data' => [
                            'type' => 'wallet',
                            'id' => '1',
                        ],
                    ],
                    'currency' => [
                        'data' => [
                            'type' => 'currency',
                            'id' => '1000',
                        ],
                    ],
                ],
            ],
        ],
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
            'Idempotency-key' => (string) Uuid::uuid4(),
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In case of a successful response, a newly created payout object is returned.

HTTP status codes

201 Success.

400 Bad request: insufficient funds.


Precalculate fee

#enterprise #merchant

For your convenience, we can calculate the blockchain fee options and processing commission before actual payout. The options for the blockchain fee are as follows: low, medium and high. For calculations, we need to know the ID of the wallet from which the payout is made, destination address and the payout amount.

Request

amount* string

The payout amount.

to_address* string

The payout destination address.

wallet* object

The payout wallet.

currency object

The payout currency. The field is requied for Merchant users and not required for Enterprise users.

POST[base]/payout/calculate/

$ curl --request POST \
       --url https://api.b2binpay.com/payout/calculate/ \
       --header 'authorization: Bearer <Change to your access token>' \
       --header 'content-type: application/vnd.api+json' \
       --data '{
           "data": {
             "type": "payout-calculation",
             "attributes": {
               "amount": "0.0000001",
               "to_address": "2N3Ac2cZzRVoqfJGu1bFaAebq3izTgr1WLv"
             },
             "relationships": {
               "wallet": {
                 "data": {
                   "type": "wallet",
                   "id": "13"
                 }
               },
               "currency": {
                 "data": {
                   "type": "currency",
                   "id": "1000"
                 }
               }
             }
           }
         }'
import requests

url = 'https://api.b2binpay.com/payout/calculate/'

headers = {
    'authorization': 'Bearer <Change to your access token>',
    'content-type': 'application/vnd.api+json',
}

data = {
   'data': {
     'type': 'payout-calculation',
     'attributes': {
       'amount': '0.0000001',
       'to_address': '2N3Ac2cZzRVoqfJGu1bFaAebq3izTgr1WLv',
     },
     'relationships': {
       'wallet': {
         'data': {
           'type': 'wallet',
           'id': '13',
         }
       },
       'currency': {
         'data': {
           'type': 'currency',
           'id': '1000',
         },
       },
     },
   },
 }

requests.post(url, headers=headers, json=data)
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
    $res = $client->post('https://api.b2binpay.com/payout/calculate/', [
        'json' => [
            'data' => [
                'type' => 'payout-calculation',
                'attributes' => [
                    'amount' => '0.05',
                    'to_address' => 'bcrt1q92k5z02dyrjahm4hput42nps3t7ryxzzz0vl76',
                ],
                'relationships' => [
                    'wallet' => [
                        'data' => [
                            'type' => 'wallet',
                            'id' => '1',
                        ],
                    ],
                    'currency' => [
                        'data' => [
                            'type' => 'currency',
                            'id' => '1000',
                        ],
                    ],
                ],
            ],
        ],
        'headers' => [
            'Authorization' => 'Bearer <Change to your access token>',
            'Content-Type' => 'application/vnd.api+json',
        ],
    ]);
    echo $res->getBody();
} catch (RequestException $e) {}

Response

In the event of success, the method returns the low, medium and high fee values. If there are no recommendations or request parameters are invalid, an error or zero low, medium and high values are returned.

is_internal boolean

If true, the payout is internal.

fee.low string

Economy mode when speed does not matter.

fee.medium string

Optimum processing speed for a reasonable fee.

fee.high string

Priority transaction processing resulting in a higher fee.

fee.currency number

The fee currency.

commission.amount object

The commission amount.

commission.currency number

The commission currency.

FEE VALUES
{
  "data": {
    "type": "payout-calculation",
    "id": "0",
    "attributes": {
      "is_internal": true,
      "fee": {
        "low": "0.00000329",
        "medium": "0.00000823",
        "high": "0.00001647",
        "dust_amount": "0.00000000",
        "currency": 1000
      },
      "commission": {
        "amount": "0.00000000",
        "currency": 1000
      }
    }
  }
}

Payout callback

#enterprise #merchant

Upon receiving a required number of confirmations of the transaction, a callback will be sent to your server if the body of the payout contains a valid callback URL. You can use it to make changes in your system and notify your users.

The callback is sent by a POST request, which contains useful JSON payload. After processing the payload, you should respond with an HTTP code 200 without a body. If your server is temporarily unavailable or the status of the response is different from 200, we will resend the callback several times with the increasing delay time. The number of resendings is limited. If the manual resending is required, you can do it via the Events for Enterprise users and Events for Merchant users.

Refer to Deposit callback for a callback example and descriptions.

Reference

Currency codes

ISO Code

Name

Blockchain

Alpha Code

Alias

Precision

Available for Merchants

1000

Bitcoin

Bitcoin

BTC

8

_images/check.png

1002

Ethereum

Ethereum

ETH

18

_images/check.png

1003

Litecoin

Litecoin

LTC

8

_images/check.png

1005

DASH

Dash

DASH

8

_images/check.png

1006

Bitcoin Cash

Bitcoin Cash

BCH

8

_images/check.png

1007

Monero

Monero

XMR

12

_images/check.png

1010

Ripple

Ripple

XRP

6

_images/check.png

1019

Dogecoin

Dogechain

DOGE

8

_images/check.png

1020

Zcash

Zcash

ZEC

8

_images/check.png

1021

Stellar

Stellar

XLM

7

_images/check.png

1026

TRON

TRON

TRX

6

_images/check.png

1125

Binance Coin

Binance Smart Chain

BNB-BSC

BNB

18

_images/check.png

2008

OMG Network

Ethereum

OMG-ETH

OMG

18

2014

USD Coin

Ethereum

USDC-ETH

USDC

6

_images/check.png

2015

TetherUS

Ethereum

USDT-ETH

USDT

6

_images/check.png

2021

Pax Dollar

Ethereum

USDP-ETH

USDP

18

_images/check.png

2022

TrueUSD

Ethereum

TUSD-ETH

TUSD

18

_images/check.png

2025

Binance Coin

Binance Chain

BNB-DEX

BNB

8

_images/check.png

2065

TetherUS

Binance Smart Chain

BUSD-T-BSC

USDT

18

_images/check.png

2068

Dai

Ethereum

DAI-ETH

DAI

18

_images/check.png

2077

Binance USD

Ethereum

BUSD-ETH

BUSD

18

_images/check.png

2085

Chainlink

Ethereum

LINK-ETH

LINK

18

_images/check.png

2100

Binance USD

Binance Smart Chain

BUSD-BSC

BUSD

18

_images/check.png

2101

Dai

Binance Smart Chain

DAI-BSC

DAI

18

_images/check.png

2102

USD Coin

Binance Smart Chain

USDC-BSC

USDC

18

_images/check.png

2103

Pax Dollar

Binance Smart Chain

USDP-BSC

USDP

18

_images/check.png

2106

Akropolis

Ethereum

AKRO-ETH

AKRO

18

2107

Alpha Finance Lab

Ethereum

ALPHA-ETH

ALPHA

18

2108

Band Protocol

Ethereum

BAND-ETH

BAND

18

_images/check.png

2110

bZx Protocol

Ethereum

BZRX-ETH

BZRX

18

2111

Chromia

Ethereum

CHR-ETH

CHR

6

2112

Compound

Ethereum

COMP-ETH

COMP

18

_images/check.png

2113

Decentraland

Ethereum

MANA-ETH

MANA

18

_images/check.png

2114

FTX Token

Ethereum

FTT-ETH

FTT

18

2115

Loopring

Ethereum

LRC-ETH

LRC

18

_images/check.png

2117

NuCypher

Ethereum

NU-ETH

NU

18

_images/check.png

2121

Reserve Rights

Ethereum

RSR-ETH

RSR

18

2122

Serum

Ethereum

SRM-ETH

SRM

6

2123

SHIBA INU

Ethereum

SHIB-ETH

SHIB

18

2125

Swipe

Ethereum

SXP-ETH

SXP

18

2126

Synthetix

Ethereum

SNX-ETH

SNX

18

_images/check.png

2128

The Sandbox

Ethereum

SAND-ETH

SAND

18

2129

Uniswap

Ethereum

UNI-ETH

UNI

18

_images/check.png

2131

Alpha Finance Lab

Binance Smart Chain

ALPHA-BSC

ALPHA

18

2132

Band Protocol

Binance Smart Chain

BAND-BSC

BAND

18

_images/check.png

2133

Basic Attention Token

Binance Smart Chain

BAT-BSC

BAT

18

_images/check.png

2134

Chainlink

Binance Smart Chain

LINK-BSC

LINK

18

_images/check.png

2135

Maker

Binance Smart Chain

MKR-BSC

MKR

18

_images/check.png

2136

Reef

Binance Smart Chain

REEF-BSC

REEF

18

2137

SushiSwap

Binance Smart Chain

SUSHI-BSC

SUSHI

18

_images/check.png

2138

Swipe

Binance Smart Chain

SXP-BSC

SXP

18

2139

Synthetix

Binance Smart Chain

SNX-BSC

SNX

18

_images/check.png

2140

Uniswap

Binance Smart Chain

UNI-BSC

UNI

18

_images/check.png

2141

yearn.finance

Binance Smart Chain

YFI-BSC

YFI

18

_images/check.png

2142

USD Coin

TRON

USDC-TRX

USDC

6

_images/check.png

2145

TetherUS

TRON

USDT-TRX

USDT

6

_images/check.png

2146

Fantom

Ethereum

FTM-ETH

FTM

18

2147

Axie Infinity

Ethereum

AXS-ETH

AXS

18

2148

Quant

Ethereum

QNT-ETH

QNT

18

2149

UNUS SED LEO

Ethereum

LEO-ETH

LEO

18

2150

TerraUSD

Ethereum

UST-ETH

UST

18

_images/check.png

2151

Amp

Ethereum

AMP-ETH

AMP

18

2152

Revain

Ethereum

REV-ETH

REV

6

2153

Chiliz

Ethereum

CHZ-ETH

CHZ

18

2154

Holo

Ethereum

HOT-ETH

HOT

18

2155

Audius

Ethereum

AUDIO-ETH

AUDIO

18

2156

Fetch.ai

Ethereum

FET-ETH

FET

18

2157

Telcoin

Ethereum

TEL-ETH

TEL

2

2160

1inch

Binance Smart Chain

1INCH-BSC

1INCH

18

2161

Ocean Protocol

Ethereum

OCEAN-ETH

OCEAN

18

2162

Balancer

Ethereum

BAL-ETH

BAL

18

2163

Badger DAO

Ethereum

BADGER-ETH

BADGER

18

2164

Rarible

Ethereum

RARI-ETH

RARI

18

2165

Fantom

Binance Smart Chain

FTM-BSC

FTM

18

2166

TerraUSD

Binance Smart Chain

UST-BSC

UST

18

_images/check.png

2942

yearn.finance

Ethereum

YFI-ETH

YFI

18

_images/check.png

2946

Maker

Ethereum

MKR-ETH

MKR

18

_images/check.png

2947

PancakeSwap

Binance Smart Chain

CAKE-BSC

CAKE

18

2948

0x

Ethereum

ZRX-ETH

ZRX

18

_images/check.png

2949

Curve DAO Token

Ethereum

CRV-ETH

CRV

18

2950

1inch

Ethereum

1INCH-ETH

1INCH

18

2951

Reef

Ethereum

REEF-ETH

REEF

18

2955

Basic Attention Token

Ethereum

BAT-ETH

BAT

18

_images/check.png

2956

Ren

Ethereum

REN-ETH

REN

18

_images/check.png

2957

Celsius

Ethereum

CEL-ETH

CEL

4

2959

Enjin Coin

Ethereum

ENJ-ETH

ENJ

18

2961

SushiSwap

Ethereum

SUSHI-ETH

SUSHI

18

_images/check.png

2962

The Graph

Ethereum

GRT-ETH

GRT

18

_images/check.png

2964

Aave

Ethereum

AAVE-ETH

AAVE

18

_images/check.png

2982

Polygon

Ethereum

MATIC-ETH

MATIC

18

_images/check.png

Block explorer list

Coins

Currency

Block explorer link

BCH

https://blockchair.com/bitcoin-cash/transaction/{address}

BNB-BSC

https://bscscan.com/tx/{address}

BNB-DEX

https://binance.mintscan.io/txs/{address}

BTC

https://www.blockchain.com/btc/tx/{address}

DASH

https://live.blockcypher.com/dash/tx/{address}

DOGE

https://live.blockcypher.com/doge/tx/{address}

ETH

https://etherscan.io/tx/{address}

LTC

https://live.blockcypher.com/ltc/tx/{address}

TRX

https://tronscan.org/#/transaction/{address}

XLM

https://stellarchain.io/tx/{address}

XMR

https://blockchair.com/monero/transaction/{address}

XRP

https://xrpscan.com/tx/{address}

ZEC

https://explorer.zcha.in/transactions/{address}

Stablecoins

Currency

Block explorer link

BUSD-BSC

https://bscscan.com/tx/{address}

BUSD-ETH

https://etherscan.io/tx/{address}

BUSD-T-BSC

https://bscscan.com/tx/{address}

DAI-BSC

https://bscscan.com/tx/{address}

DAI-ETH

https://etherscan.io/tx/{address}

TUSD-ETH

https://etherscan.io/tx/{address}

USDC-BSC

https://bscscan.com/tx/{address}

USDC-ETH

https://etherscan.io/tx/{address}

USDC-TRX

https://tronscan.org/#/transaction/{address}

USDP-BSC

https://bscscan.com/tx/{address}

USDP-ETH

https://etherscan.io/tx/{address}

USDT-ETH

https://etherscan.io/tx/{address}

USDT-TRX

https://tronscan.org/#/transaction/{address}

UST-BSC

https://bscscan.com/tx/{address}

UST-ETH

https://etherscan.io/tx/{address}

Tokens

Currency

Block explorer link

1INCH-BSC

https://bscscan.com/tx/{address}

1INCH-ETH

https://etherscan.io/tx/{address}

AAVE-ETH

https://etherscan.io/tx/{address}

AKRO-ETH

https://etherscan.io/tx/{address}

ALPHA-BSC

https://bscscan.com/tx/{address}

ALPHA-ETH

https://etherscan.io/tx/{address}

AMP-ETH

https://etherscan.io/tx/{address}

AXS-ETH

https://etherscan.io/tx/{address}

BADGER-ETH

https://etherscan.io/tx/{address}

BAL-ETH

https://etherscan.io/tx/{address}

BAND-BSC

https://bscscan.com/tx/{address}

BAND-ETH

https://etherscan.io/tx/{address}

BAT-BSC

https://bscscan.com/tx/{address}

BAT-ETH

https://etherscan.io/tx/{address}

BZRX-ETH

https://etherscan.io/tx/{address}

CAKE-BSC

https://bscscan.com/tx/{address}

CHR-ETH

https://etherscan.io/tx/{address}

CHZ-ETH

https://etherscan.io/tx/{address}

COMP-ETH

https://etherscan.io/tx/{address}

CRV-ETH

https://etherscan.io/tx/{address}

ENJ-ETH

https://etherscan.io/tx/{address}

FET-ETH

https://etherscan.io/tx/{address}

FTM-BSC

https://bscscan.com/tx/{address}

FTM-ETH

https://etherscan.io/tx/{address}

FTT-ETH

https://etherscan.io/tx/{address}

GRT-ETH

https://etherscan.io/tx/{address}

HOT-ETH

https://etherscan.io/tx/{address}

LINK-BSC

https://bscscan.com/tx/{address}

LINK-ETH

https://etherscan.io/tx/{address}

LRC-ETH

https://etherscan.io/tx/{address}

MANA-ETH

https://etherscan.io/tx/{address}

MATIC-ETH

https://etherscan.io/tx/{address}

MKR-BSC

https://bscscan.com/tx/{address}

MKR-ETH

https://etherscan.io/tx/{address}

NU-ETH

https://etherscan.io/tx/{address}

OCEAN-ETH

https://etherscan.io/tx/{address}

OMG-ETH

https://etherscan.io/tx/{address}

QNT-ETH

https://etherscan.io/tx/{address}

RARI-ETH

https://etherscan.io/tx/{address}

REEF-BSC

https://bscscan.com/tx/{address}

REEF-ETH

https://etherscan.io/tx/{address}

REN-ETH

https://etherscan.io/tx/{address}

RSR-ETH

https://etherscan.io/tx/{address}

SAND-ETH

https://etherscan.io/tx/{address}

SHIB-ETH

https://etherscan.io/tx/{address}

SNX-BSC

https://bscscan.com/tx/{address}

SNX-ETH

https://etherscan.io/tx/{address}

SRM-ETH

https://etherscan.io/tx/{address}

SUSHI-BSC

https://bscscan.com/tx/{address}

SUSHI-ETH

https://etherscan.io/tx/{address}

SXP-BSC

https://bscscan.com/tx/{address}

SXP-ETH

https://etherscan.io/tx/{address}

UNI-BSC

https://bscscan.com/tx/{address}

UNI-ETH

https://etherscan.io/tx/{address}

YFI-BSC

https://bscscan.com/tx/{address}

YFI-ETH

https://etherscan.io/tx/{address}

ZRX-ETH

https://etherscan.io/tx/{address}

Deposit and invoice address types

Currency

Types Available

Default

Description

BTC

legacy, p2sh-segwit

p2sh-segwit

LTC

legacy, p2sh-segwit, bech32

bech32

BCH

legacy, cash

cash

The data.attributes.destination object will contain an array of two types of addresses at once

XRP

address, x-address

x-address

The data.attributes.destination object will contain an array of two types of addresses at once

UUID tools

Here you can find a list of UUID tools for the most popular programming languages:

HMAC tools

Here you can find a list of HMAC tools for the most popular programming languages:

Callback verification

<?php

# set API user login and password
$login = 'E8kOq803ktB7';
$password = 'E8kOq803ktB7';

# parse callback data
$callback_payload = json_decode(
    '
{
  "data": {
    "type": "payout",
    "id": "26",
    "attributes": {
      "address": "2NBr9k5xhvE2PxAAiFuczqQkeN76ShMdRZ6",
      "created_at": "2021-09-30T13:01:49.930612Z",
      "tracking_id": "12",
      "fee_amount": "0.00000823",
      "is_fee_included": false,
      "amount": "0.00010000",
      "destination": {
        "address_type": "legacy",
        "address": "2NBr9k5xhvE2PxAAiFuczqQkeN76ShMdRZ6"
      }
    },
    "relationships": {
      "wallet": {
        "data": {
          "type": "wallet",
          "id": "19"
        }
      },
      "currency": {
        "data": {
          "type": "currency",
          "id": "1000"
        }
      },
      "transfer": {
        "data": {
          "type": "transfer",
          "id": "145"
        }
      }
    }
  },
  "included": [
    {
      "type": "currency",
      "id": "1000",
      "attributes": {
        "iso": 1000,
        "name": "Bitcoin",
        "alpha": "BTC",
        "alias": null,
        "exp": 8,
        "confirmation_blocks": 3,
        "minimal_transfer_amount": "0.00000546",
        "block_delay": 3600
      }
    },
    {
      "type": "transfer",
      "id": "145",
      "attributes": {
        "confirmations": 3,
        "risk": 0,
        "risk_status": 4,
        "op_id": 26,
        "op_type": 2,
        "amount": "0.00010000",
        "commission": "0.00000000",
        "fee": "0.00000823",
        "txid": "c3cc36f4569fdbfaacdbc14647e5046d9f239ab1af0268b531a5a213411a8fc9",
        "status": 2,
        "message": null,
        "user_message": null,
        "created_at": "2021-09-30T13:01:50.273446Z",
        "updated_at": "2021-09-30T13:02:33.743770Z"
      },
      "relationships": {
        "currency": {
          "data": {
            "type": "currency",
            "id": "1000"
          }
        }
      }
    }
  ],
  "meta": {
    "time": "2021-09-30T13:02:34.059939+00:00",
    "sign": "8ef2a0f0c6826895593d0d137cf6ce7353a4bbe999d4a6c363f92f1e9d7f8e32"
  }
}
',
    true
    );

$callback_sign = $callback_payload['meta']['sign'];
$callback_time = $callback_payload['meta']['time'];

# retrieve transfer and deposit attributes
$included_transfer = array_filter(
    $callback_payload['included'],
    function ($item) {
        return $item['type'] === 'transfer';
    }
);
$included_transfer = array_pop($included_transfer)['attributes'];
$deposit = $callback_payload['data']['attributes'];

$status = $included_transfer['status'];
$amount = $included_transfer['amount'];
$tracking_id = $deposit['tracking_id'];

# prepare data for hash check
$message = $status . $amount . $tracking_id . $callback_time;
$hash_secret = hash('sha256', $login . $password, true);
$hash_hmac_result = hash_hmac('sha256', $message, $hash_secret);

# print result
if ($hash_hmac_result === $callback_sign) {
    echo 'Verified';
} else {
    echo 'Invalid sign';
}
echo PHP_EOL;

Auth verification

// "crypto-js": "4.0.0" is installed as a dependency
const SHA256 = require("crypto-js/sha256");
const hmacSHA256 = require('crypto-js/hmac-sha256');

// set API user login and password
const login = 'nQns0adI5CZNj';
const password = '3BXNFKKthfRk07tM';

// parse /api/token/ response payload
const authResponse = JSON.parse("{\n" +
    "  \"data\": {\n" +
    "    \"type\": \"auth-token\",\n" +
    "    \"id\": \"0\",\n" +
    "    \"attributes\": {\n" +
    "      \"refresh\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUz\",\n" +
    "      \"access\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI\",\n" +
    "      \"access_expired_at\": \"2020-08-24T13:50:12.192479+03:00\",\n" +
    "      \"refresh_expired_at\": \"2020-08-24T19:33:33.192479+03:00\",\n" +
    "      \"is_2fa_confirmed\": false\n" +
    "    }\n" +
    "  },\n" +
    "  \"meta\": {\n" +
    "    \"time\": \"2020-08-24T10:33:33.192479Z\",\n" +
    "    \"sign\": \"e70adec551e26b560049e42aa0993ae42cac4e03fbbb300320d8be\"\n" +
    "  }\n" +
    "}");
    
// prepare data for hash check
const message = authResponse['meta']['time'] + authResponse['data']['attributes']['refresh'];
const responseSign = authResponse['meta']['sign'];
const secret = SHA256(login + password);
const calculatedSign = hmacSHA256(message, secret).toString();

// print result
if (responseSign === calculatedSign) {
    console.log('Verified');
} else {
    console.log('Invalid sign');
}