Merchants (Payment gateway)
OxaPay crypto gateway is usable for online business websites, telegram bots, software, applications and etc. Using and setting up the OxaPay crypto payment gateway service is not complicated. Just follow the three steps below:
OxaPay needs your order information to set up your gateway, which can be sent through this endpoint. If the parameters are sent correctly, you will receive
trackId
as the payment tracking ID in response to this endpoint.By sending the generated
trackId
in the previous step to this endpoint, the payment page will appear for you and you are ready to pay.OxaPay sends the payment status of each order to the callback URL (you have registered it for your merchant). After that, you need to call the transaction confirmation method. It is possible to confirm the successful payment through this endpoint.
If you need to receive information and transaction status in any of the payment steps, by calling this endpoint, you will receive the full details of the desired transaction.
By following the mentioned steps, the payment process of the order ends. The deposit amount will be deposited to your OxaPay wallet through the payment gateway.
OxaPay uses the
merchant
parameter to validate the available gateways. After creating each new gateway, this information is available in the OxaPay user panel. All requests sent to OxaPay must contain authentication information:You can use
oxapay
as merchant
field in all requests to test the payment service.{
"merchant": "oxapay",
// OTHER FIELDS
}
Use this endpoint to send order information and register it in the OxaPay system.
post
https://api.oxapay.com
/merchants/request
Parameters
Body
merchant*
String
Require for authentication
amount*
Long
Total amount (as dollar if currency filed was not filled. Otherwise amount should be filled with your specified currency amount)
callbackUrl*
String
Payment informations will be sent to this URL
currency
String
If you want that your invoice to be paid by a specified currency fill in this field with its symbol (Find the list of currencies symbol in the accepted coins section)
description
String
Order details (will be shown in different reports)
orderId
String
Your unique order ID (optional - used in reports)
email
String
User's email for report
Responses
200: OK
Successful operation
Sample JSON you sent to this endpoint
{
"merchant": "oxapay",
"amount": 22.22,
"callbackUrl": "https://www.site.com/yourCallback",
"description": "Hello World!",
"orderId": "AB-1122",
"email": "[email protected]"
}
Sample JSON response from OxaPay for this endpoint
{
"result": 100,
"message": "success",
"trackId": 7423199,
"payLink": "https://oxapay.com/mpay/7423199"
}
100 | Successful operation |
102 | |
103 | Invalid merchant |
104 | Inactive merchant |
105 | Amount is less than the acceptable amount |
106 | Amount is more than the acceptable amount |
107 | Currency is not acceptable or was sent wrong |
108 | callbackUrl not entered or entered incorrectly |
php
Node.js
Python
<?php
â
define('OXAPAY_MERCHANT_KEY', 'YOUR-MERCHANT-KEY');
â
function oxapayRequest($path, $params)
{
$url = 'https://oxapay.com/merchants/'.$path;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return json_decode($res);
}
â
$params = array(
'merchant' => OXAPAY_MERCHANT_KEY, //required
'amount' => 12.12, //required, usd
'callbackUrl' => 'https://www.site.com/yourCallback' //required
'description' => 'Hello World!', //optional
'orderId' => 'AB-1122', //optional
'email' => '[email protected]', //optional
);
â
$res = oxapayRequest('request', $params);
if ($res->result == 100)
{
// store $res->trackId and redirect to $res->payLink url
}
else{
echo "errorCode: ".$res->result."<br>";
echo "message: ".$res->message;
}
â
?>
var request = require('request-promise');
var params = {
merchant: "YOUR-MERCHANT-KEY",
amount: 22.22,
callbackUrl: "https://www.site.com/yourCallback",
description: "Hello World!",
orderId: "AB-1122",
email: "[email protected]"
};
var options = {
method: "POST",
url: "https://api.oxapay.com/merchants/request",
headers: {
'cache-control': 'no-cache',
'content-type': 'application/json'
},
body: params,
json: true
};
request(options)
.then(function (res) {
if (res.result == 100) {
// store res.trackId and redirect to res.payLink url
}
})
import requests
â
params = {
'merchant': 'oxapay',
'amount': 22.22,
'callbackUrl': "http://localhost:3333/callback",
'description': "Hello World!",
'orderId': "ORD-1122",
'email': "[email protected]",
}
url = "https://api.oxapay.com/merchants/request"
response = requests.post(url = url, json= params)
â
res = response.json()
if res['result'] == 100:
# store res['trackId'] and redirect to res['payLink'] urlth
Use this endpoint to display the payment page and start paying.
get
https://oxapay.com
/mpay/{{trackId}}
By sending the
trackId
to the above address and opening this page in the browser, you will be transferred to the OxaPay payment page.Parameters
No parameters
Responses
OxaPay sends the payment information to the entered
callbackUrl
in your request when the status changes.This information is sent as Query String and through the
GET
method for callbackUrl
.To end the payment session of an order, if the payment is successful, be sure to confirm the received information through the payment confirmation gateway.
success | 1 for the successful transaction, 0 otherwise. |
trackId | Payment session tracking ID |
orderId | Order ID sent when payment request (if sent in request endpoint) |
status |
The called callback example
https://site.com/yourcallback?trackId=7423199&success=1&status=2&orderId=AB-1122
Use this endpoint to confirm successful payment and end a payment session.
As mentioned earlier, OxaPay notifies you of the status of payment by sending payment information to the registered callbackUrl. This endpoint is installed to ensure that you receive this information and complete the order payment process.
post
https://api.oxapay.com
/merchants/verify
Parameters
Body
merchant*
String
Require for authentication
trackId*
Long
The ID of the payment session you want to confirm
Responses
200: OK
Successful operation
Sample JSON you sent to this endpoint
{
"merchant": "oxapay",
"trackId": 7423199
}
Sample JSON response from OxaPay for this endpoint
{
"paidAt": "2023-01-10T13:23:01",
"amount": 22.22,
"result": 100,
"status": 1,
"message": "success"
}
100 | Successful operation |
102 | |
103 | Invalid merchant |
104 | Inactive merchant |
201 | Already approved |
202 | |
203 | Invalid trackId |
php
Node.js
Python
<?php
â
define('OXAPAY_MERCHANT_KEY', 'YOUR-MERCHANT-KEY');
â
function oxapayRequest($path, $params)
{
$url = 'https://oxapay.com/merchants/'.$path;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return json_decode($res);
}
â
if($_GET['success']==1) {
//start verfication
$params = array(
'merchant' => OXAPAY_MERCHANT_KEY, //required
'trackId' => $_GET['trackId'], //required
);
â
$res = oxapayRequest('verify', $params);
if ($res->result == 100) {
var_dump($res);
// store $res->transaction data
}
else{
echo "errorCode: ".$res->result."<br>";
echo "message: ".$res->message;
}
}else{
echo "The order has not been paid or has failed";
}
?>
var express = require("express");
var request = require('request-promise');
â
var app = express();
â
app.listen(3333, () => {
console.log("Server running on port 3333");
});
â
app.get("/callback", (req, res) => {
â
// store order status here
â
res.json({ result: 100, message: "success" })
if (req.query.success == '1' && req.query.status == '2') {
var params = {
merchant: "YOUR-MERCHANT-KEY",
trackId: req.query.trackId
};
var options = {
method: "POST",
url: "https://api.oxapay.com/merchants/verify",
headers: {
'cache-control': 'no-cache',
'content-type': 'application/json'
},
body: params,
json: true
};
request(options)
.then(function (res) {
if (res.result == 100) {
// store res.transaction data
}
})
}
})
from http.server import BaseHTTPRequestHandler, HTTPServer
import urllib
import requests
â
class Server(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
req = dict(urllib.parse.parse_qsl(urllib.parse.urlparse(self.path).query))
print(req)
if req["success"] == '1' and req["status"] == '2':
params = {
'merchant': "YOUR-MERCHANT-KEY",
'trackId': req["trackId"]
}
url = "https://api.oxapay.com/merchants/verify"
response = requests.post(url = url, json= params)
res = response.json()
if res['result'] == 100:
# store res['transaction'] data
â
â
def run(server_class=HTTPServer, handler_class=Server, port=3333):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print('Starting httpd on port %d...' % port)
httpd.serve_forever()
if name == "__main__":
from sys import argv
if len(argv) == 2:
run(port=int(argv[1]))
else:
run()
Use this endpoint to inquire about payment and receive a report of a payment session.
post
https://api.oxapay.com
/merchants/inquiry
Parameters
Body
merchant*
String
Require for authentication
trackId*
Long
The ID of the payment session you want to get its report
Responses
200: OK
Successful operation
Sample JSON you sent to this endpoint
{
"merchant": "oxapay",
"trackId": 7423199
}
Sample JSON response from OxaPay for this endpoint
{
"message": "success",
"result": 100,
"paidAt": "2023-01-10T13:23:01",
"verifiedAt": "2023-01-10T13:25:43",
"status": 1,
"amount": 22.22,
"orderId": "AB-1122",
"description": "Hello World !",
"email": "[email protected]",
"wage": 0,
"createdAt": "2023-01-10T13:06:21",
"transaction": {
"coin": "trx", // Paid currency symbol
"amount": 409.04, // paid currency amount
"txId": "xxx", // Paid transaction hash
}
}
100 | Successful operation |
102 | |
103 | Invalid merchant |
104 | Inactive merchant |
203 | Invalid trackId |
php
Node.js
Python
<?php
â
define('OXAPAY_MERCHANT_KEY', 'YOUR-MERCHANT-KEY');
â
function oxapayRequest($path, $params)
{
$url = 'https://oxapay.com/merchants/'.$path;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return json_decode($res);
}
â
$params = array(
'merchant' => OXAPAY_MERCHANT_KEY, //required
'trackId' => YOUR-PAYMENT-REQUEST-TRACKID, //required
);
$res = oxapayRequest('inquiry', $params);
if ($res->result == 100)
{
var_dump($res);
//{"result":100,"message":"success","createdAt":"2023-01-08T00:26:46+00:00","paidAt":"2023-01-08T02:28:36+00:00","amount":1,"status":2,"wage":"0","description":"test","orderId":"AB-12345","email":"[email protected]","transaction":{"coin":"trx","txId":"txhash","amount":20}}
}
else{
echo "errorCode: ".$res->result."<br>";
echo "message: ".$res->message;
}
â
?>
var request = require('request-promise');
var params = {
merchant: "YOUR-MERCHANT-KEY",
trackId: YOUR-PAYMENT-REQUEST-TRACKID
};
var options = {
method: "POST",
url: "https://api.oxapay.com/merchants/inquiry",
headers: {
'cache-control': 'no-cache',
'content-type': 'application/json'
},
body: params,
json: true
};
request(options)
.then(function (res) {
if (res.result == 100) {
// store order status and res.transaction data
}
})
import requests
â
params = {
'merchant': "YOUR-MERCHANT-KEY",
'trackId': YOUR-PAYMENT-REQUEST-TRACKID
}
url = "https://api.oxapay.com/merchants/inquiry"
response = requests.post(url = url, json= params)
res = response.json()
if res['result'] == 100:
# store res['transaction'] data
Use this endpoint to get the list of your merchant's accepted coins.
post
https://api.oxapay.com
/merchants/allowedCoins
Parameters
Body
merchant*
String
Require for authentication
Responses
200: OK
Successful operation
Sample JSON you sent to this endpoint
{
"merchant": "oxapay"
}
Sample JSON response from OxaPay for this endpoint
{
"result": 100,
"message": "success",
"allowed": ['btc', 'eth', 'bnb', 'usdt(trc20)', 'usdt(erc20)']
}
100 | Successful operation |
102 | |
103 | Invalid merchant |
104 | Inactive merchant |
php
Node.js
Python
<?php
â
define('OXAPAY_MERCHANT_KEY', 'YOUR-MERCHANT-KEY');
â
function oxapayRequest($path, $params)
{
$url = 'https://oxapay.com/merchants/'.$path;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return json_decode($res);
}
â
$params = array(
'merchant' => OXAPAY_MERCHANT_KEY, //required
);
$res = oxapayRequest('allowedCoins', $params);
if ($res->result == 100)
{
var_dump($res);
//{"result":100,"message":"success","allowed":["btc","eth","ltc","bnb","trx","usdt(trc20)","usdt(erc20)"]}
}
else{
echo "errorCode: ".$res->result."<br>";
echo "message: ".$res->message;
}
â
?>
var request = require('request-promise');
var params = {
merchant: "YOUR-MERCHANT-KEY",
};
var options = {
method: "GET",
url: "https://api.oxapay.com/merchants/allowedCoins",
headers: {
'cache-control': 'no-cache',
'content-type': 'application/json'
},
body: params,
json: true
};
request(options)
.then(function (res) {
if (res.result == 100) {
// store res.allowed array
}
})
import requests
â
params = {
'merchant': "YOUR-MERCHANT-KEY"
}
url = "https://api.oxapay.com/merchants/allowedCoins"
response = requests.post(url = url, json= params)
res = response.json()
if res['result'] == 100:
# store res['allowed'] array
-3 | Canceled by the user |
-2 | Unsuccessful payment |
-1 | Payment pending |
1 | Paid, verified |
2 | Paid, Not verified |
Last modified now