API payment gateway xPayapi
SCI PHP Classes
Download and connect PHP classes to receive payments and benefits.
Detailed DocumentationxPayApi SCI
SCI | Check payment(for IPN)
Method name: sci_confirm_order
. This method is used in the handler of the payment receipt. The handler is called automatically by the xPayApi.com service until the script responds order_id|success
(maximum 5 times, otherwise you need to send a notification manually from the profile). The payment processor is called automatically from the notification servers 103.134.152.4. These IP(s) need to be added to the exceptions of your FireWall or DDoS filter, so that notifications go smoothly. The current list of IP can be obtained in text format via the URL: https://xpayapi.com/ips.txt or in JSON format: https://xpayapi.com/ips.php. The server sends a POST request, in which it passes a order_id (random string), system (the name of the payment system or currency), currency (abbreviated currency name), order_id (payment id in your project). Next you must pass the received order_id in the SCI request to the sci_confirm_order method, which will allow you to check whether the payment was successful.
https://api.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
func required | String |
Method name, must be: sci_confirm_order Default value: |
sci_id required | String |
Merchant ID |
sci_key required | String |
Merchant Password |
order_id required | String |
Result from POST request |
test required | Boolean |
Turn on test mode Default value: Allowed values:
|
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
Information required | String |
message |
data required | Object |
Extradata |
transaction required | String |
Invoice ID in xPayApi |
shop_id required | String |
Merchant ID in xPayApi |
order_id required | String |
Payment ID in your merchant |
amount required | String |
Amount to be received |
currency required | String |
Name of currency |
system required | String |
Name of system |
address required | String |
Destination address |
tag required | String |
Tag for Ripple and Stellar |
hash required | String |
Uuid of payment link |
HTTP/1.1 200 OK
{
"error": false,
"message": "Payment successfully verified",
"data": {
"transaction": "25487", // transaction number in the system xpayapi: 25487
"shop_id": "123", // Merchant ID 123
"order_id": "12345", // unique numeric identifier of the payment in your merchant, example: 12345
"amount": "2.123456", // invoice amount example: 2.123456
"currency": "BTC", // currency(USD, RUB, BTC, ETH, LTC, DOGE, DASH, BCH, ETC, XRP, TRX, XLM, BNB, USDT, BUSD, USDC, ADA, EOS, SHIB)
"system": "Bitcoin", // system(Bitcoin, Ethereum, Litecoin, Dogecoin, Dash, BitcoinCash, Zcash, EthereumClassic, Ripple, TRON, Stellar, BinanceCoin_BEP20, TRON_TRC20, BinanceSmartChain_BEP20, Ethereum_ERC20)
"address": "bc1qgd5jezucgjkrnp00h8fcq8wsxacwf65d88j7gf", //Destination address
"tag": "", //Tag for Ripple and Stellar
"hash": "ba276492c1c8ff5bfad7ea46463aca85d9c447ee940aceeb71e4a726d89458cd", //uuid of payment link
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "Account not found",
"data": {}
}
SCI | Get transaction details
Method name: sci_transaction_details
. This method should be called to get and check transaction information.
https://api.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
func required | String |
Method name, must be: sci_transaction_details Default value: |
sci_id required | String |
Merchant ID |
sci_key required | String |
Merchant Password |
order_id required | String |
Result from POST request |
test required | Boolean |
Must be false only Default value: Allowed values:
|
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
Information required | String |
message |
data required | Object |
Extradata |
transaction required | String |
Invoice ID in xPayApi |
txid required | String |
Public transaction hash for track transfer |
shop_id required | String |
Merchant ID in xPayApi |
order_id required | String |
Payment ID in your merchant |
amount required | String |
Amount to be received |
fee required | String |
Fee of network |
currency required | String |
Name of currency |
system required | String |
Name of system |
address required | String |
Destination address |
tag required | String |
Tag for Ripple and Stellar |
status required | String |
"no" - not confirmed, "yes" - confirmed and credited |
date_update required | String |
Date last change transaction info |
explorer_address_link required | String |
Link to address explorer |
explorer_transaction_link required | String |
Link to transaction explorer |
HTTP/1.1 200 OK
{
"error": false,
"message": "Ok",
"data": {
"transaction": "2431038", // transaction number in the system xpayapi: 96401
"txid": "e2be8b51ad0ccbae2a2433f8c940035ce97903c7de1a1cefa1db40cc1cabb0e5", //Hash track for explorer
"shop_id": "138", // Merchant ID 123
"order_id": "order 1", // unique numeric identifier of the payment in your merchant, example: 150800
"amount": "1.00000000", // amount to credited example: 1.01
"fee": "0.00000000", // fee of network
"currency": "DOGE", // currency(USD, RUB, BTC, ETH, LTC, DOGE, DASH, BCH, ETC, XRP, TRX, XLM, BNB, USDT, BUSD, USDC, ADA, EOS, SHIB)
"system": "Dogecoin", //system(BitCoin, Ethereum, Litecoin, Dogecoin, Dash, BitcoinCash, Zcash, EthereumClassic, Ripple, TRON, Stellar, BinanceCoin_BEP20, TRON_TRC20, BinanceSmartChain_BEP20, Ethereum_ERC20)
"address": "DKpzDZuFoTpPpnpsMro8NBtmDz8rinCjqp", //Target address
"tag": "", //Tag for Ripple and Stellar
"status": "no", //"no" - not confirmed, "yes" - confirmed and credited
"date_update": "2020-07-23 15:06:58", //Date last change transaction info
"explorer_address_link": "https://explorer.xpayapi.com/dogecoin/address/DKpzDZuFoTpPpnpsMro8NBtmDz8rinCjqp", //Link to address explorer
"explorer_transaction_link": "https://explorer.xpayapi.com/dogecoin/transaction/e2be8b51ad0ccbae2a2433f8c940035ce97903c7de1a1cefa1db40cc1cabb0e5" //Link to transaction explorer
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "Account not found",
"data": {}
}
SCI | Get cryptocurrency address for deposit
Method name: sci_create_order_get_data
. Creates an address to receive payment. After creating an address for payment, you need to display it on your project page along with a small instruction on how to pay.
https://api.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
func required | String |
Method name, must be: sci_create_order_get_data Default value: |
sci_id required | String |
Merchant ID |
sci_key required | String |
Merchant Password |
order_id required | String |
Payment ID in your merchant |
amount required | String |
Amount to be received |
currency required | String |
Currency to be received Allowed values:
|
system required | Number |
ID of system must match currency Allowed values:
|
comment required | String |
Comments for history |
paid_commission required | String |
Who paid commission (only fiat, default: shop) Default value: Allowed values:
|
test required | Boolean |
Turn on test mode Default value: Allowed values:
|
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
Information required | String |
message |
data required | Object |
Extradata |
invoice required | String |
Invoice ID in xPayApi |
order_id required | String |
Payment ID in your merchant |
address required | String |
Destination address |
amount required | String |
Amount to be received |
system required | String |
Name of system |
currency required | String |
Name of currency |
notif_url required | String |
URL to redirect user for paying process |
pay_link required | String |
URL to redirect user for paying invoice using xPayapi gateway |
tag required | String |
Optional if not false, you must pass he payeer |
HTTP/1.1 200 OK
{
"error": false,
"message": "Data has been successfully received.",
"data": {
"invoice": "579205",
"order_id": "12345",
"address": "bc1qgd5jezucgjkrnp00h8fcq8wsxacwf65d88j7gf", // address to pay
"amount": "1.03030000",
"system": "BitCoin",
"currency": "BTC",
"notif_url": "https://xpayapi.com/notif_url.php", # link to redirect for IPN
"pay_link": "https://pay.xpayapi.com/sci/hash/ba276492c1c8ff5bfad7ea46463aca85d9c447ee940aceeb71e4a726d89458cd", # link to pay the invoice
"tag": false // not false if exists
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "Specify the payment amount. Error code: 22",
"data": {}
}
xPayApi API
API | Get Balance of merchant
Method name: api_get_shop_balance.
Get balance of merchant.
https://api.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
func required | String |
Method name, must be: api_get_shop_balance Default value: |
api_id required | String |
API ID |
api_key required | String |
API Password |
shop_id required | String |
Merchant ID |
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
Information required | String |
message |
data required | Object |
Extradata - cointain pairs key system name and currency name(ex. BinanceCoin BNB => "binancecoin_bnb") from https://coinmarketcap.com in lowercase, value current balance |
HTTP/1.1 200 OK
{
"error": false,
"message": "Balance store successfully received.",
"data": {
"berty_rub": "12236.12",
"berty_usd": "11503.00",
"bitcoin_btc": "9.19148781",
"ethereum_eth": "12.65759653",
"litecoin_ltc": "10.81039547",
"dogecoin_doge": "1055330.30324031",
"dash_dash": "12.08654262",
"bitcoincash_bch": "230.00235701",
"ripple_xrp": "130977.938830",
"tron_trx": "15003.120000",
"stellar_xlm": "150325.0002350",
"binancecoin_bep20": "1525.003350",
"tron_trc20_usdt": "100.0000",
"binancesmartchain_bep20_usdt": "100.0000",
"binancesmartchain_bep20_shib": "100300.003423400",
"ethereum_erc20_usdt": "100.0000",
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "Access is denied. Error code: 10.",
"data": {}
}
API | Get currency rate for pair
Method name: api_currency_rate.
Get currency rate for pair. Attention!!! Instead of the xpayapi.com domain, you should use the currency.xpayapi.com subdomain.
https://currency.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
currency_in required | String |
From currency Allowed values:
|
currency_out required | String |
To currency Allowed values:
|
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
message required | String |
Success message |
data required | Object |
Extradata |
value required | String |
Current rate currency_in / currency_out |
HTTP/1.1 200 OK
{
"error": false,
"message": "Ok",
"data": {
"value": "52873.18000000"
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "Wrong currency_out!",
"data": {}
}
API | Instant payment
Method name: api_payment.
This is an instant payment method designed for executing automatic mass payments from your merchant account.
https://api.xpayapi.com/index.php
Parameter
Field | Type | Description |
---|---|---|
func required | String |
A method name, must be: api_payment Default value: |
api_id required | String |
An API ID |
api_key required | String |
An API Password |
shop_id required | String |
An Merchant ID |
amount required | String |
The amount that will be sent (transferred to the recipient) |
currency required | String |
Currency to be received Allowed values:
|
system required | String |
ID of system must match currency Allowed values:
|
number required | String |
An address of a recipient, ex. bc1qgd5jezucgjkrnp00h8fcq8wsxacwf65d88j7gf |
tag required | Number |
A tag of Ripple or Stellar if the one is required Allowed values:
|
priority required | String |
The parameter influences the order in which a transaction is included into a block (BitCoin, Litecoin, Dogecoin, Dash, BitcoinCash) Default value: Allowed values:
|
test required | String |
Turn on/off a test mode Default value: Allowed values:
|
require_once 'xpayapi_api.class.php';
$xpayapi_config = [
"merchant_id" => "Merchant ID",
"merchant_password" => "Merchant Password",
"api_id" => "API ID",
"api_password" => "API Password",
"config" => [
"test_mode" => false,
],
];
$system_id = [
"bitcoin" => 20, // BTC
"ethereum" => 21, // ETH
"litecoin" => 22, // LTC
"dash" => 23, // DASH
"dogecoin" => 24, // DOGE
"binancecoin_bep20" => 25, // BNB BEP20
"tron" => 26, // TRX
"tron_trc20" => 27, // USDT TRC20
"binancesmartchain_bep20" => 28, // USDT BEP20
"binancesmartchain_bep20" => 33, // SHIB BEP20
"ethereum_erc20" => 32, // USDT ERC20
];
$xPayApi_params = [
"merchant_id" => $xpayapi_config["merchant_id"],
"wallet" => [
"address" => "TRdjwv1fHZvzs3m3fbLxh9fhguNtxLVfWD",
"tag" => "",
],
"amount" => "5",
"system" => "TRON",
"currency" => "TRX",
"comment" => "Testing comment",
"priority" => "low", // low, medium, high
];
$xPayApi = new \xPayApi\xPayApiAPI(
$xpayapi_config["api_id"],
$xpayapi_config["api_password"],
$xpayapi_config["config"]["test_mode"]
);
$res = $xPayApi->sendMoney(
$xPayApi_params["merchant_id"],
$xPayApi_params["wallet"],
$xPayApi_params["amount"],
$xPayApi_params["system"],
$xPayApi_params["currency"],
$xPayApi_params["priority"],
$xPayApi_params["comment"]
);
if ($res['error']) {
echo $res["message"]; // $res["message"] - the text of the error message
//actions in case of an error
} else {
//actions in case of success
$merchant_id = $res["data"]["shop_id"]; // merchant id that you originally made payment, example 122
$transaction = $res["data"]["transaction"]; // transaction number of the payment, example 123456
$txid = $res["data"]["txid"]; // txid 5b74e07821da048e4efe3182420fd717bbafd4c0f6f7f2f48a8fe8e55eb923df can be empty
// In this case, the information about the transaction can be obtained using a universal link from the Explorer_Transaction_Link field, see below
$payment_id = $res["data"]["payment_id"]; // Payment transaction number in the payment system, example 59363855
$amount = $res["data"]["amount"]; // the amount of the payment, how much was written off from the balance of the merchant
$amount_pay = $res["data"]["amount_pay"]; // the amount of the payment, as it is the user
$system = $res["data"]["system"]; // the system of payment, which was made the payment, example: Bitcoin
$currency = $res["data"]["currency"]; // the payment currency, for example: BTC
$number = $res["data"]["number"]; // the address where you sent the funds
$fee_percent = $res["data"]["fee_percent"];// the transfer fee percentage, example: 1.5 (in %)
$fee_amount = $res["data"]["fee_amount"]; // the transfer fee amount, example: 1.00
$paid_commission = $res["data"]["paid_commission"]; // who paid for the Commission, for example: shop
$explorer_address_link =
$res["data"]["explorer_address_link"]; // A link to view information about the address
$explorer_transaction_link =
$res["data"]["explorer_transaction_link"]; // Link to view transaction information
echo sprintf(
'We have sent the %s %s %s to %s. The txid is %s',
$system,
$amount,
$currency,
$explorer_address_link,
$number,
$explorer_transaction_link,
$txid
);
}
Success 200
Field | Type | Description |
---|---|---|
error required | Boolean |
false - Success |
message required | String |
An information of a message |
data required | Object |
An extra data |
shop_id required | String |
Merchant ID of Xpayapi |
transaction required | String |
Transaction number of Xpayapi.com |
payment_id required | String |
Transaction number of payment system |
txid required | String |
Transaction number of CoinNetwork |
amount required | String |
Amount of the payment charge from balance |
amount_pay required | String |
Amount of the payment to balance target wallet |
system required | String |
Name of system(Berty(USD,RUB), Bitcoin(BTC), Ethereum(ETH), Litecoin(LTC), Dogecoin(DOGE), Dash(DASH), BitcoinCash(BCH), EthereumClassic(ETC), Ripple(XRP), TRON(TRX), Stellar(XLM), BinanceCoin_BEP20(BNB), TRON_TRC20(USDT), BinanceSmartChain_BEP20(USDT), BinanceSmartChain_BEP20(SHIB), Ethereum_ERC20(USDT) |
currency required | String |
Name of currency(USD, RUB, BTC, ETH, LTC, DOGE, DASH, BCH, ETC, XRP, TRX, XLM, BNB, USDT, BUSD, USDC, ADA, EOS, SHIB) |
number required | String |
Address where you sent the funds |
fee_percent required | String |
Fee % value |
fee_amount required | String |
Fee fix value |
paid_commission required | String |
Who paid commission |
explorer_address_link required | String |
A link to view information about the address |
explorer_transaction_link required | String |
Link to view transaction information |
HTTP/1.1 200 OK
{
"error": false,
"message": "Data has been successfully received.",
"data": {
"shop_id": "123", // id merchant from which you made the payment, example 122
"transaction": "130236", // transaction number of the payment, example 130236
"payment_id": "478937139", // transaction number of the payment system, example 478937139
"txid": "70d6dc6841782c6efd8deac4b44d9cc3338fda7af38043dd47d7cbad7e84d5dd" // txid 70d6dc6841782c6efd8deac4b44d9cc3338fda7af38043dd47d7cbad7e84d5dd
"amount": "1.01", // the amount of the payment, how much was written off from the balance store 0.42
"amount_pay": "1.0306", // the amount of the payment, as it is the user, example: 0.41
"system": "BitCoin", // system, example: Berty(USD,RUB), BitCoin(BTC), Ethereum(ETH), Litecoin(LTC), Dogecoin(DOGE), Dash(DASH), BitcoinCash(BCH), EthereumClassic(ETC), Ripple(XRP), TRON(TRX), Stellar(XLM), BinanceCoin_BEP20(BNB), TRON_TRC20(USDT), BinanceSmartChain_BEP20(USDT), BinanceSmartChain_BEP20(SHIB), Ethereum_ERC20(USDT)
"currency": "BTC", // the currency of payment, for example: USD, RUB, BTC, ETH, LTC, DOGE, DASH, BCH, ETC, XRP, XLM, BNB, USDT, BUSD, USDC, ADA, EOS, SHIB
"number": "bc1qgd5jezucgjkrnp00h8fcq8wsxacwf65d88j7gf", // the address where you sent the funds
"shop_comission_percent": "1.5", // the transfer fee percentage, example: 1.5
"shop_comission_amount": "1.0", // the transfer fee amount, example: 1.00
"paid_commission": "shop" // who paid for the commission, for example: shop
"explorer_address_link": "https://explorer.xpayapi.com/tron/address/TQsGVya16tiMQgybR5M4xAD4pwjRioqa21" // A link to view information about the address
"explorer_transaction_link": "https://explorer.xpayapi.com/tron/transaction/70d6dc6841782c6efd8deac4b44d9cc3338fda7af38043dd47d7cbad7e84d5dd" // Link to view transaction information
}
}
Error 4xx
Name | Type | Description |
---|---|---|
error required | Boolean |
true - Fail |
message required | String |
Error description |
data required | Object |
Empty |
HTTP/1.1 200 OK
{
"error": true,
"message": "There is not enough money on the account. Error code: 5.",
"data": {}
}