ПОСЛЕДНЕЕ ОБНОВЛЕНИЕ API:
2023/12/08
(new parameters - [amount_plus] and [amount_percent] in $coins)

Если вы не знаете как работать с API или не хотите писать код для своего проекта - можете использовать наши Безлимитные платёжные ссылки (UPL)
Вы сможете создать ссылку без знания языков программирования и даже если у вас нет сайта! Используйте любые монеты, p2p переводы и прочие фишки от PayCrypto.

Также, вы можете создать собственный бот-магазин в Telegram - ещё более удобный способ продавать свои товары. Ссылка на бота - ShopsRobot

API URL:

METHOD: getrates

Получить актуальные курсы обмена монет.
GET

Пример ответа JSON:

{
    "btc": {
        "btc": "1",
        "eth": "14.900315",
        "trx": "310559.0062111801",
        "ton": "15429.7176361673",
        "ltc": "368.309",
        "bch": "171.639",
        "xrp": "39162",
        "dash": "463.3254722445",
        "bnb": "70.288",
        "doge": "318471.3375796179",
        "usdt": "19193.8579654511",
        "busd": "19197.5427145325",
        "dai": "19193.8579654511",
        "usd": "19201.58",
        "rub": "1236649",
        "eur": "19743.36",
        "try": "356831",
        "inr": "1578972"
    },
    "eth": {
        "btc": "0.06706181",
        "eth": "1",
        "trx": "20846.3623097769",
        "ton": "1034.7682119205",
        "ltc": "24.715759",
        "bch": "11.518016",
        "xrp": "2628",
        "dash": "31.0714073763",
        "bnb": "4.716732",
        "doge": "21326.5088505012",
        "usdt": "1287.5315445228",
        "busd": "1287.4155133569",
        "dai": "1287.6973396173",
        "usd": "1288.54",
        "rub": "82987",
        "eur": "1324.9",
        "try": "23946",
        "inr": "105959"
    },
    {
        ...
    }
}

METHOD: info

Получить актуальную информацию о вашем аккаунте.
GET

Пример ответа JSON:

{
    "plan": "-",
    "subscription": 0,
    "webhooks_per_day": 0,
    "requests_per_day": 0,
    "rate_limit_this_method": "1 query per 10 secs"
}

METHOD: getpaylink

Запросить СЧЁТ для вашего клиента. Необходимо отправить JSON в теле POST запроса.
POST

Полный пример JSON в теле POST запроса:

{
    "lang": "en", //required, en||ru
    "title": "Title of your invoice", //required
    "desc": "Decription of your invoice", //required
    //You can use BB-CODEs: [url=link]link[/url], [b]bold[/b], [i]em[/i], [u]underline[/u], [color=#color]color text[/color]
    "amount": 60, //required, int or float, >0 (this amount will be converted by paycrypto for every coin, which does not have own amount)
    "amount_currency": "usd", //required
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "ok_link": "back link for customer when transaction completed", //required, allowed: A-Z, a-z, 0-9, _.-/:?=
    "cancel_link": "back link for customer when he cancel payment", //required, allowed: A-Z, a-z, 0-9, _.-/:?=
    "webhook_link": "link to your script where PayCrypto will send webhook, when transaction totally get all confirmations", //required, allowed: A-Z, a-z, 0-9, _.-/:?=
    "coins": { //required, list of coins, that will show on payment page
    //[btc, bch, eth, ethusdt, ethdai, trx, trxusdt, ltc, dash, ton, doge, bnb, bnbusdt, bnbdai, busd, xrp]
        "ton": {
            "address": "Your ton address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount": 100.002342 //optional, int or float (if you specify - paycrypto will not convert this amount)
        },
        "xrp": {
            "address": "Your xrp address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "tag": 123445 //required only if coin = xrp
        },
        "btc": {
            "address": "Your btc address" //required, allowed: A-Z, a-z, 0-9, -_=:
        },
        "ltc": {
            "address": "Your ltc address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount_plus": 50 //optional, allowed numbers (-, 0-9) (if specify - paycrypto will use own rates, but add/subtract this amount to result)
        },
        "doge": {
            "address": "Your doge address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount_percent": 10 //optional, allowed numbers (-, 0-9) (if specify - paycrypto will use own rates, but add/subtract this percents to result)
        },
        "trxusdt": {
            "address": "Your trx address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount": 61 //optional, int or float (if you specify - paycrypto will not convert this amount)
        } //and so on, you can use all coins, and if you want even change addresses in each request..
    },
    "other": { //optional, if specify - will be returned with webhook
        "user_id": 12345, //any pair of key and value, key allowed: A-Z, a-z, 0-9, _, value allowed: A-Z, a-z, 0-9, _.-/:
        "order_id": "pc_23482",
        "something": "any string",
        "and_so_on": "..."
    },
    "customization": {//optional, not allowed on PLAN S, allowed params: background||logo||logo_text||logo_link
        "background": "fff", //or "background": "Direct link to image", optional (you can use colors without # or images), allowed: A-Z, a-z, 0-9, _.-/:
        "logo": "Direct link to image", //optional, allowed: A-Z, a-z, 0-9, _.-/:
        "logo_text": "Custom header of invoice", //optional, allowed: A-Z, a-z, 0-9, _.-/:
        "logo_link": "Direct link to your project" //optional, allowed: A-Z, a-z, 0-9, _.-/:
    }
}

Пример PHP:

<?php
$json['lang'] = 'en';
$json['title'] = 'Test invoice #123';
$json['desc'] = 'Custom description for my invoice';
//You can use BB-CODEs: [url=link]link[/url], [b]bold[/b], [i]em[/i], [u]underline[/u], [color=#color]color text[/color]
$json['amount'] = 60;
$json['amount_currency'] = "eur";
//[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
$json['ok_link'] = "https://paycrypto.global/docs";
$json['cancel_link'] = "https://paycrypto.global";
$json['webhook_link'] = "https://paycrypto.global/my_script_for_incoming_webhooks";
//$json['coins'] = ARRAY of coins (you can use all in each invoice)
//customer sees these coins as different payment methods on invoice page
//you can set ..[coin]['address'], ..[coin]['amount'], ..[coin]['tag'] (tag - only for xrp)
//look coins list
$json['coins']['btc']['address'] = "mybtcaddress1234";
$json['coins']['trx']['address'] = "myTRXaddress";
$json['coins']['trx']['amount'] = 1579.123456; //optional
//if you specify amount paycrypto will not convert $json['amount'] for this coin
$json['coins']['trxusdt']['address'] = "myTRXaddress";
$json['coins']['xrp']['address'] = "myXRPaddress";
$json['coins']['xrp']['tag'] = 19384532;
$json['coins']['ltc']['address'] = "myLTCaddress";
$json['coins']['ltc']['amount_plus'] = 50; //optional
//if you use amount_plus - you can't use amount_percent, amount_plus tells paycrypto convert $json['amount'] with own rates, and add/subtract ['amount_plus'] to result
$json['coins']['doge']['address'] = "myDOGEaddress";
$json['coins']['doge']['amount_percent'] = 10; //optional
//if you use amount_percent - you can't use amount_plus, amount_percent tells paycrypto convert $json['amount'] with own rates, and add/subtract ['amount_plus'] percents to result
//$json['other'] = ARRAY of key->value (PayCrypto will add this info in webhook)
//$json['other']['your_key'] = 'your_value';
$json['other']['customer_id'] = 129483435;
$json['other']['password'] = 'abc34de56';
$json['other']['product_id'] = 'book_145';
//customization NOT available on plan S
$json['customization']['background'] = 'https://paycrypto.global/assets/img/custom-bg-1.svg';
$json['customization']['logo'] = 'https://paycrypto.global/assets/img/logo.png';
$json['customization']['logo_text'] = 'PayCrypto Store';

$url = "https://paycrypto.global/api/***your_api_key***/getpaylink";    
$content = json_encode($json);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-type: application/json"]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);
curl_close($curl);

$decode_answer = json_decode($json_response, true);
$pay_link = $decode_answer['paylink'];
//show link to customer and so on...
?>

Пример ответа JSON:

{
    "paylink": "https://paycrypto.global/invoice/pwc0e30lclswr5t"
}

METHOD: getpayment

Оплата на стороне ВАШЕГО проекта без перехода на нашу платёжную страницу. Метод доступен только с U тарифом. Необходимо отправить JSON в теле POST запроса.
POST

Полный пример JSON в теле POST запроса:

{
    "amount": 60, //required, int or float, >0 (this amount will be converted by paycrypto for every coin, which does not have own amount)
    "amount_currency": "usd", //required
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "webhook_link": "link to your script where PayCrypto will send webhook, when transaction totally get all confirmations", //required, allowed: A-Z, a-z, 0-9, _.-/:?=
    "coins": { //required, list of coins
    //[btc, bch, eth, ethusdt, ethdai, trx, trxusdt, ltc, dash, ton, doge, bnb, bnbusdt, bnbdai, busd, xrp]
        "ton": {
            "address": "Your ton address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount": 100.002342 //optional, int or float (if you specify - paycrypto will not convert this amount)
        },
        "xrp": {
            "address": "Your xrp address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "tag": 123445 //required only if coin = xrp
        },
        "btc": {
            "address": "Your btc address" //required, allowed: A-Z, a-z, 0-9, -_=:
        },
        "ltc": {
            "address": "Your ltc address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount_plus": -50 //optional, allowed numbers (-, 0-9) (if specify - paycrypto will use own rates, but add/subtract this amount to result)
        },
        "doge": {
            "address": "Your doge address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount_percent": -10 //optional, allowed numbers (-, 0-9) (if specify - paycrypto will use own rates, but add/subtract this percents to result)
        },
        "trxusdt": {
            "address": "Your trx address", //required, allowed: A-Z, a-z, 0-9, -_=:
            "amount": 61 //optional, int or float (if you specify - paycrypto will not convert this amount)
        } //and so on, you can use all coins, and if you want even change addresses in each request..
    },
    "other": { //optional, if specify - will be returned with webhook
        "user_id": 12345, //any pair of key and value, key allowed: A-Z, a-z, 0-9, _, value allowed: A-Z, a-z, 0-9, _.-/:
        "order_id": "pc_23482",
        "something": "any string",
        "and_so_on": "..."
    },
}

Пример PHP:

<?php
$json['amount'] = 60;
$json['amount_currency'] = "eur";
//[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
$json['webhook_link'] = "https://paycrypto.global/my_script_for_incoming_webhooks";
//$json['coins'] = ARRAY of coins (you can use all in each invoice)
//customer sees these coins as different payment methods on invoice page
//you can set ..[coin]['address'], ..[coin]['amount'], ..[coin]['tag'] (tag - only for xrp)
//look coins list
$json['coins']['btc']['address'] = "mybtcaddress1234";
$json['coins']['trx']['address'] = "myTRXaddress";
$json['coins']['trx']['amount'] = 1579.123456; //optional
//if you specify amount paycrypto will not convert $json['amount'] for this coin
$json['coins']['trxusdt']['address'] = "myTRXaddress";
$json['coins']['xrp']['address'] = "myXRPaddress";
$json['coins']['xrp']['tag'] = 19384532;
$json['coins']['ltc']['address'] = "myLTCaddress";
$json['coins']['ltc']['amount_plus'] = -50; //optional
//if you use amount_plus - you can't use amount_percent, amount_plus tells paycrypto convert $json['amount'] with own rates, and add/subtract ['amount_plus'] to result
$json['coins']['doge']['address'] = "myDOGEaddress";
$json['coins']['doge']['amount_percent'] = -10; //optional
//if you use amount_percent - you can't use amount_plus, amount_percent tells paycrypto convert $json['amount'] with own rates, and add/subtract ['amount_plus'] percents to result
//$json['other'] = ARRAY of key->value (PayCrypto will add this info in webhook)
//$json['other']['your_key'] = 'your_value';
$json['other']['customer_id'] = 129483435;
$json['other']['password'] = 'abc34de56';
$json['other']['product_id'] = 'book_145';

$url = "https://paycrypto.global/api/***your_api_key***/getpayment";    
$content = json_encode($json);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-type: application/json"]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);
curl_close($curl);

$decode_answer = json_decode($json_response, true);
$tron_amount_to_pay = $decode_answer['coins']['trx']['amount'];
$invoice_time = $decode_answer['invoice_ttl'];
//show coins list with amounts to your customer and so on...
?>

Пример ответа JSON:

{
    "link": "xxxxxxxxxxxxxxx", //link of your invoice
    "amount": 60, //amount of your invoice
    "amount_currency": "eur", //currency of your invoice
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "coins": {
    //coins that you set
        "trx": {
            "amount": "1577.489355", //EXACTLY amount that your customer has to pay to your wallet
            "convert": "paycrypto", //who calculate rates you or we? "paycrypto||shop"
            "address": "TRON ADDRESS" //your crypto currency address
        },
        "trxusdt": {
            "amount": "123.00",
            "convert": "paycrypto",
            "address": "TRON ADDRESS",
            "tag": "chain: TRC-20" //sometimes you can see TAG - for example with chain info or MEMO for XRP
        },
        "btc": {
            "amount": "0.00450154",
            "convert": "paycrypto",
            "address": "BITCOIN ADDRESS"
        },
        "ltc": {
            "amount": "12.3402",
            "amount_plus": -50,
            "convert": "shop",
            "address": "LITECOIN ADDRESS"
        },
        "doge": {
            "amount": "12.3402",
            "amount_percent": -10,
            "convert": "shop",
            "address": "DOGECOIN ADDRESS"
        },
        //and so on
    },
    "other": {
    //other information that you gave (KEY - VALUE)
        "user_id": 12345,
        "order_id": "pc_23482",
        "something": "any string"
    },
    "webhook_link": "Direct link to your script", //where PayCrypto will send webhook, when transaction totally get all confirmations
    "invoice_ttl": TIMESTAMP //when invoice will be deleted and PayCrypto will stop to wait transaction from your customer
}

Список монет (для API)

JSON[amount_currency] usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp
JSON[coins][coin] btc, bch, eth, ethusdt, ethdai, trx, trxusdt, ltc, dash, ton, doge, bnb, bnbusdt, bnbdai, busd, xrp

Необходимое число подтверждений для разных монет:

btc = 3 bch = 6 eth = 30 usdt ERC-20 = 12 dai ERC-20 = 12 trx = 20 usdt TRC-20 = 20 ltc = 6 dash = 6 ton = 1 doge = 50 bnb = 12 usdt BEP-20 = 12 dai BEP-20 = 12 busd BEP-20 = 12 xrp = 1

WEBHOOKS (уведомления)

Когда клиент откроет счёт по ссылке ИЛИ транзакция получит все необходимые подтверждения, PayCrypto отправит уведомление (POST запрос с JSON в теле) на ваш скрипт.
Если хотите протестировать вебхуки, пожалуйста посетите: paycrypto.global/try_webhook
Мы отправляем уведомления только с этих IP адресов: 92.255.107.43, 185.119.56.59, 185.178.44.137, 185.178.46.40, 185.178.47.148, 185.178.47.161, 45.146.166.226, 45.146.167.195, 45.146.167.90, 185.230.141.121, 185.230.141.122, 45.151.137.4

Пример уведомления (счёт был открыт) (json, post):

{
    "webhook_type": "invoice_link_opened", //PLEASE, ALWAYS CHECK THE TYPE OF WEBHOOK.
    "link": "xxxxxxxxxxxxxxx", //link of your invoice
    "amount": 60, //amount of your invoice
    "amount_currency": "rub", //currency of your invoice
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "other": {
    //other information that you gave (KEY - VALUE)
        "user_id": 12345,
        "order_id": "pc_23482",
        "something": "any string"
    },
    "ok_link": "Direct link", //Where to redirect your customers after GOOD PAYMENT
    "cancel_link": "Direct link", //Where to redirect your customers if they will CANCEL PAYMENT
    "webhook_link": "Direct link to your script", //just dublicate
    "invoice_ttl": TIMESTAMP //invoice will be deleted at this moment and PayCrypto will stop to check income transactions to your addresses.
}

Пример уведомления (новая транзакция) (1 отправка) (json, post):

{
    "webhook_type": "new_transaction", //PLEASE, ALWAYS CHECK THE TYPE OF WEBHOOK.
    "shop_link": "xxxxxxxxxxxxxxx", //link of your invoice
    "shop_amount": 10, //amount of your invoice
    "shop_currency": "usd", //currency of your invoice
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "customer_amount": "10.00", //amount paid by your customer
    "customer_currency": "usdt", //customer's currency
    //[btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "input_wallet": "your address", //your address that got transaction
    "input_tx_hash": "transaction hash", //transaction id
    "confirmations": 1, //quantity of confirmations
    "other": {
    //other information that you gave (KEY - VALUE)
        "user_id": 12345,
        "order_id": "pc_23482",
        "something": "any string"
    },
    "webhook_link": "Direct link to your script" //just dublicate
}

Пример уведомления (успешная транзакция) (json, post):

{
    "webhook_type": "payment_done", //PLEASE, ALWAYS CHECK THE TYPE OF WEBHOOK.
    "shop_link": "xxxxxxxxxxxxxxx", //link of your invoice
    "shop_amount": 60, //amount of your invoice
    "shop_currency": "rub", //currency of your invoice
    //[usd, rub, eur, try, inr, thb, uah, btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "customer_amount": "0.000000100", //amount paid by your customer
    "customer_currency": "ton", //customer's currency
    //[btc, bch, eth, usdt, trx, ltc, dash, ton, doge, dai, bnb, busd, xrp]
    "input_wallet": "your address", //your address that got transaction
    "input_tx_hash": "transaction hash", //transaction id
    "other": {
    //other information that you gave (KEY - VALUE)
        "user_id": 12345,
        "order_id": "pc_23482",
        "something": "any string"
    },
    "webhook_link": "Direct link to your script" //just dublicate
}

Пример PHP:

<?php
if (!in_array($_SERVER['REMOTE_ADDR'], ['92.255.107.43', '185.119.56.59', '185.178.44.137', '185.178.46.40', '185.178.47.148', '185.178.47.161', '45.146.166.226', '45.146.167.195', '45.146.167.90', '185.230.141.121', '185.230.141.122', '45.151.137.4'])) exit;
//block other IPs

$input = file_get_contents('php://input');
//get JSON from paycrypto

$decode = json_decode($input, 1);
//decode JSON from paycrypto

if($decode['webhook_type'] == 'invoice_link_opened'){
    //the webhook is sent only for getpaylink method
    //now you know that your customer opened your invoice and you can do something using information from $decode array
    exit;
}

if($decode['webhook_type'] == 'new_transaction'){
    //the webhook is sent only if it is a new transaction that has fewer confirmations than necessary
    //now you know that your customer made transaction and you can do something using information from $decode array
    exit;
}

if($decode['webhook_type'] == 'payment_done'){
    //top up balance, or make something for your customer here using information from $decode array
    exit;
}
?>