Important note for API v2 users
In order to use the system you need an API key. Getting a key is free and easy, sign up here: https://www.paybear.io Once registered, you can manage the currencies you want to integrate in the Membership area / Currencies. Please enable the currencies there before using this API.GET | https://api.paybear.io/v3/currencies?token={token} |
token | API Secret Key |
GET | https://api.paybear.io/v3/{crypto}/payment/{callback_url}?token={token}&lock_address_timeout={lock_address_timeout} |
crypto | Crypto currency to accept (eth, btc, bch, ltc, dash, btg, etc) or ERC20 token in "erc20:xxx" format where xxx is a token symbol, e.g. eos |
token | API Secret Key |
callback_url | Your server callback url (urlencoded) |
lock_address_timeout | Time interval in seconds during which the address is locked for this invoice only. 86400 seconds by default. Set -1 for infinite lock |
The API always responds with a JSON string. [data] collection contains the important values: [address] is the payment address to show to the customer [invoice] is our inner payment identifier, keep it in a safe place and never disclose to your clients.
{
"success": true,
"data": {
"invoice": "d1ddf6e3767030b08032cf2eae403600",
"address": "0x2073eb3be1a41908e0353427da7f16412a01ae71"
}
}
Address "0x2073eb3be1a41908e0353427da7f16412a01ae71" has been locked for this invoice for one hour.
More examples: Node.js, Ruby on Rails$orderId = 12345;
$apiSecret = 'YOURSECRET'; //your api key
$callbackUrl = 'http://CHANGEME.com/callback.php?id='.$orderId;
$lockAddressTimeout = 3600;
$url = sprintf('https://api.paybear.io/v3/eth/payment/%s?token=%s&lock_address_timeout=%s', urlencode($callbackUrl), $apiSecret, $lockAddressTimeout);
if ($response = file_get_contents($url)) {
$response = json_decode($response);
if (isset($response->data->address)) {
echo $response->data->address;
//save $response->data->invoice and keep it secret
}
}
{
"invoice": "7e691214bebe31eaa4b813c59825391b",
"confirmations": 2,
"maxConfirmations": 4,
"blockchain": "eth",
"block": {
"number": 4316966,
"hash": "0xf80718e3021cc6c226a01ea69b98131cd9b03fa5a0cac1f2469cc32d0f09e110"
},
"inTransaction": {
"hash": "0x7e29e165d15ec1c6fc0b71eed944471308c10d0450fe7e768843241f944bdfde",
"exp": 18,
"amount": 21000000000000
}
}
Note: blockchain could be a crypto currency code (eth, btc ...) or ERC20 token in erc20:xxx format where xxx is a token symbol, e.g. eos
More examples: Node.js, Ruby on Railsconst CONFIRMATIONS = 3;
$orderId = $_GET['id'];
$data = file_get_contents('php://input');
if ($data) {
$params = json_decode($data);
$invoice = $params->invoice;
$amount = $params->inTransaction->amount
if ($params->confirmations>=$params->maxConfirmations) {
//compare $amount with order total
//compare $invoice with one saved in the database to ensure callback is legitimate
//mark the order as paid
echo $invoice; //stop further callbacks
} else {
die("waiting for confirmations");
}
}
GET | https://api.paybear.io/v3/exchange/{fiat}/rate?date={date}&time={time} |
fiat | Fiat currency (usd, eur, cad, rub etc) |
date | The date in ISO format, e.g. 2018-06-30 |
time | The time in UNIX format, e.g. 1530780455 |
{
"success": true,
"data": {
"ltc": {
"poloniex": 340.986909455,
"hitbtc": 340.568,
"bittrex": 340.25,
"bitfinex": 341.295,
"mid": 340.77497736375
},
"eth": {
"poloniex": 804.580989955,
"hitbtc": 805.88,
"bittrex": 803.47641155,
"bitfinex": 805.125,
"mid": 804.76560037625
},
"dash": {
"poloniex": 1129.8512215,
"hitbtc": 1130.145,
"bittrex": 1134.1035001,
"mid": 1131.3665738666666
},
"btg": {
"hitbtc": 320.485,
"bittrex": 317.90500002,
"bitfinex": 320.46500003,
"mid": 319.61833334
},
"btc": {
"poloniex": 17348.94643245,
"hitbtc": 17322.91,
"bittrex": 17347.05,
"bitfinex": 17355.5,
"mid": 17343.6016081125
},
"bch": {
"poloniex": 2595.49999996,
"hitbtc": 2600.6334100004,
"bitfinex": 2591.55,
"mid": 2595.8944699866665
}
}
}
GET | https://api.paybear.io/v3/{crypto}/exchange/{fiat}/rate?date={date}&time={time} |
crypto | Crypto currency (eth, btc, bch, ltc, dash, btg) or ERC20 token in "erc20:xxx" format where xxx is a token symbol, e.g. eos |
fiat | Fiat currency (usd, eur, cad, rub etc) |
date | The date in ISO format, e.g. 2018-06-30 |
time | The time in UNIX format, e.g. 1530780455 |
{
"success": true,
"data": {
"poloniex": 301.71905,
"bittrex": 302.05,
"bitfinex": 301.53499,
"mid": 301.76807
}
}
$url = "https://api.paybear.io/v3/eth/exchange/usd/rate";
if ($response = file_get_contents($url)) {
$response = json_decode($response);
if ($response->success) {
echo $response->data->mid;
}
}
You will need payout addresses for all crypto currencies you want to accept. Only you will have access to your payout wallets. You can use any online wallet, service or exchange of your choice. If you don't have one, consider reading our Wallet Guide