Eng | Chi

介绍

正式API接口端点:

			
https://{Request from us}/merchant
			
		

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

			
https://{Request from us}/merchant
			
		

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 使用deposit_bank_list api 来获取银行号。
  6. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  7. 您的网页将转接您的客户去SonicPay的付款连接。
  8. 客户将在付款页面选择付款选项然后付款。
  9. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "rate": [
        {
            "currency": "MYR",
            "min": 420.0000,
            "max": 42000.0000
        },
        {
            "currency": "SGD",
            "min": 134.0000,
            "max": 13400.0000
        }
    ]
}
			
		

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "auth": "t5IF5r2fXit1FnhjBVQv"
}
			
		

返回例子 (失败):

			
{
    "status": false,
    "message": "Params incorrect"
}
			
		

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

			
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "THB"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$customer_bank_holder_name = "tang"; //客户银行持有人姓名
$customer_bank_account = "1234"; //客户银行账户
$bank_id = "105"; //银行号
$pay_method  = "thaiqr"; //其中1个选项 : "thaiqr" , "truemoney"
$callback_url  = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
	  'username' => $username, 
	  'auth' => $auth, 
	  'amount' => $amount, 
	  'currency' => $currency, 
	  'orderid' => $orderid,
	  'email' => $email, 
	  'phone_number' => $phone_number,
	  'redirect_url' => $redirect_url,
	  'customer_bank_holder_name' => $customer_bank_holder_name,
	  'customer_bank_account' => $customer_bank_account,
	  'bank_id' => $bank_id,
	  'pay_method' => $pay_method
	  'callback_url' => $callback_url
	);
	
$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
    "payment_id": "123456_1_123"
}
			
		

返回例子 (失败):

			
//当客户邮件参数信息错误 
{
    "status": false,
    "message": "email incorrect."
}
			
		

返回例子 (失败):

			
//当参数不齐全
{
    "status": false,
    "message": "Params missing."
}
			
		

返回例子 (失败):

			
//当代理商订单号错误或已存在
{
    "status": false,
    "message": "Order ID Exist."
}
			
		

返回例子 (失败):

			
//当付款数额错误或超过限额
{
    "status": false,
    "message": "Invalid Amount."
}
			
		

返回例子 (失败):

			
//当认证码错误
{
    "status": false,
    "message": "Params incorrect."
}
			
		

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

			
{
    "order_id": "20073",
    "amount": 300.0000,
    "currency": "THB",
    "order_status":"completed",
    "status": true,
    "charge": "9.0000",
    "token":"cb2a91e02770eda1c42d7485f9048913",
    "name":"john doe",
    "type":"deposit",
   
} 
			
		

返回例子(创建订单) - 失败:

			
{
    "order_id": "Example_123",
    "amount": 25.0000,
    "currency": "THB",
    "order_status":"fail",
    "status": true,
    "token":"aZ3423432CWWSDFssdf",
    "charge":"5.00",
    "type":"deposit",
}   
			
		

返回例子(提款) - 成功:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "THB",
    "order_status":"completed",
    "status": true,
    "charge": "5.00",
    "token":"5bf30f18349ce1211fdb0c7aff4d439b",
    "name":"John Doe",
    "type":"withdrawal",
    "remarks":"Success",
}  
			
		

返回例子(提款) - 失败:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "THB",
    "order_status":"fail",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

返回例子(提款) - 拒绝:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "THB",
    "order_status":"rejected",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

提款訂單接口

请求例子:

			
<?php
$auth = "Payment-test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "THB"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$bank_id = "12"; //可从查詢提款銀行列表接口拿到
$bank_branch = "Kentucky"; //可選的
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字. 
$account_no = "12332343432"; //接收者银行账号
$callback_url = "https://abc.com/withdraw/callback"; //回调地址 (可选)

$send = array(
	  'auth' => $auth,
	  'amount' => $amount,
	  'currency' => $currency,
	  'orderid' => $orderid,
	  'bank_id' => $bank_id,
	  'bank_branch' => $bank_branch,
	  'holder_name' => $holder_name,
	  'account_no' => $account_no,
	  'callback_url' => $callback_url,
	);
	
$apiurl = "https://{Request from us}/merchant/withdraw_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子(成功):

			
{
    "status": true,
    "message": "Success",
    "payment_id": "015459_330_164",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params incorrect",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params missing.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "bank_id invalid.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Balance not enough!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Amount Invalid!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Order id exist!",
}
			
		

想要在SonicPay創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.

接下來把提款訂單和認證碼發送去提款訂單接口.

查詢存款銀行列表

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$currency = "THB"; //可選的, 货币代号

$send = array(
	  'username' => $username,
	  'currency' => $currency
	);
	
$apiurl = "https://{Request from us}/wallet/bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "data": [
        {
            "currency": "THB",
            "bank_name": "Siam Commercial Bank",
            "id": "1"
        },
        {
            "currency": "THB",
            "bank_name": "Siam Commercial Bank",
            "id": "2"
        }
    ]
}
			
		

呼叫存款銀行列表接口來獲取存款銀行列表信息。

查詢提款銀行列表

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$currency = "THB"; //可選的, 货币代号

$send = array(
	  'username' => $username,
	  'currency' => $currency
	);
	
$apiurl = "https://{Request from us}/wallet/withdraw_bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "data": [
        {
            "currency": "THB",
            "bank_name": "Siam Commercial Bank",
            "id": "1"
        },
        {
            "currency": "THB",
            "bank_name": "Siam Commercial Bank",
            "id": "2"
        }
    ]
}
			
		

呼叫提款銀行列表接口來獲取提款銀行列表信息。

查询状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "THB",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "THB",
}
			
		

返回例子 – 有待:

			
{
    "status": true,
    "order_status": "pending",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "THB",
}
			
		

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

查询提款状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户提款订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_withdraw_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "THB",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "THB",
}
			
		

返回例子 – 有待:

			
{
    "status": true,
    "order_status": "proccess",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "THB",
}
			
		

返回例子 – 拒绝:

			
{
    "status": true,
    "order_status": "rejected",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "THB",
}
			
		

在SonicPay查询提款状态接口,您可以使用Username和ID查询您的提款状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "THB"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。

介绍

正式API接口端点:

			
https://{Request from us}/merchant
			
		

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

			
https://{Request from us}/merchant
			
		

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  6. 您的网页将转接您的客户去SonicPay的付款连接。
  7. 客户将在付款页面选择付款选项然后付款。
  8. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "rate": [
        {
            "currency": "MYR",
            "min": 420.0000,
            "max": 42000.0000
        },
        {
            "currency": "SGD",
            "min": 134.0000,
            "max": 13400.0000
        }
    ]
}
			
		

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "auth": "t5IF5r2fXit1FnhjBVQv"
}
			
		

返回例子 (失败):

			
{
    "status": false,
    "message": "Params incorrect"
}
			
		

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

			
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "CNY"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$pay_method  = "alipay"; // 其中1个选项 : alipay, wechatpay, cny_ob
$callback_url = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
	  'username' => $username, 
	  'auth' => $auth, 
	  'amount' => $amount, 
	  'currency' => $currency, 
	  'orderid' => $orderid,
	  'email' => $email, 
	  'phone_number' => $phone_number,
	  'redirect_url' => $redirect_url,
	  'pay_method' => $pay_method,
	  'callback_url' => $callback_url
	);
	
$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
    "payment_id": "123456_1_123"
}
			
		

返回例子 (失败):

			
//当客户邮件参数信息错误 
{
    "status": false,
    "message": "email incorrect."
}
			
		

返回例子 (失败):

			
//当参数不齐全
{
    "status": false,
    "message": "Params missing."
}
			
		

返回例子 (失败):

			
//当代理商订单号错误或已存在
{
    "status": false,
    "message": "Order ID Exist."
}
			
		

返回例子 (失败):

			
//当付款数额错误或超过限额
{
    "status": false,
    "message": "Invalid Amount."
}
			
		

返回例子 (失败):

			
//当认证码错误
{
    "status": false,
    "message": "Params incorrect."
}
			
		

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

			
{
    "order_id": "20073",
    "amount": 300.0000,
    "currency": "CNY",
    "order_status":"completed",
    "status": true,
    "charge": "9.0000",
    "token":"cb2a91e02770eda1c42d7485f9048913",
    "name":"john doe",
    "type":"deposit",
   
} 
			
		

返回例子(创建订单) - 失败:

			
{
    "order_id": "Example_123",
    "amount": 25.0000,
    "currency": "CNY",
    "order_status":"fail",
    "status": true,
    "token":"aZ3423432CWWSDFssdf",
    "charge":"5.00",
    "type":"deposit",
}   
			
		

返回例子(提款) - 成功:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "CNY",
    "order_status":"completed",
    "status": true,
    "charge": "5.00",
    "token":"5bf30f18349ce1211fdb0c7aff4d439b",
    "name":"John Doe",
    "type":"withdrawal",
    "remarks":"Success",
}  
			
		

返回例子(提款) - 失败:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "CNY",
    "order_status":"fail",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

返回例子(提款) - 拒绝:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "CNY",
    "order_status":"rejected",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

提款訂單接口

请求例子:

			
<?php
$auth = "Payment-test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "CNY"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$bank_id = "12"; //可从查詢提款銀行列表接口拿到
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字. 
$account_no = "12332343432"; //接收者银行账号
$callback_url = "https://abc.com/withdraw/callback"; //回调地址 (可选)

$send = array(
	  'auth' => $auth,
	  'amount' => $amount,
	  'currency' => $currency,
	  'orderid' => $orderid,
	  'bank_id' => $bank_id,
	  'holder_name' => $holder_name,
	  'account_no' => $account_no,
	  'callback_url' => $callback_url,
	);
	
$apiurl = "https://{Request from us}/merchant/withdraw_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子(成功):

			
{
    "status": true,
    "message": "Success",
    "payment_id": "015459_330_164"
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params incorrect",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params missing.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "bank_id invalid.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Balance not enough!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Amount Invalid!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Order id exist!",
}
			
		

想要在SonicPay創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.

接下來把提款訂單和認證碼發送去提款訂單接口.

查詢提款銀行列表

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$currency = "CNY"; //可選的, 货币代号

$send = array(
	  'username' => $username,
	  'currency' => $currency
	);
	
$apiurl = "https://{Request from us}/wallet/withdraw_bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "data": [
        {
            "currency": "CNY",
            "bank_name": "Siam Commercial Bank",
            "id": "1"
        },
        {
            "currency": "CNY",
            "bank_name": "Siam Commercial Bank",
            "id": "2"
        }
    ]
}
			
		

呼叫提款銀行列表接口來獲取提款銀行列表信息。

查询状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "CNY",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "CNY",
}
			
		

返回例子 – 有待:

			
{
    "status": true,
    "order_status": "pending",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "CNY",
}
			
		

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

查询提款状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户提款订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_withdraw_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "CNY",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "CNY",
}
			
		

返回例子 – 待定:

			
{
    "status": true,
    "order_status": "proccess",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "CNY",
}
			
		

返回例子 – 拒绝:

			
{
    "status": true,
    "order_status": "rejected",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "CNY",
}
			
		

在SonicPay查询提款状态接口,您可以使用Username和ID查询您的提款状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "CNY"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。

介绍

正式API接口端点:

			
https://{Request from us}/merchant
			
		

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

			
https://{Request from us}/merchant
			
		

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  6. 您的网页将转接您的客户去SonicPay的付款连接。
  7. 客户将在付款页面选择付款选项然后付款。
  8. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "rate": [
        {
            "currency": "MYR",
            "min": 420.0000,
            "max": 42000.0000
        },
        {
            "currency": "SGD",
            "min": 134.0000,
            "max": 13400.0000
        }
    ]
}
			
		

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "auth": "t5IF5r2fXit1FnhjBVQv"
}
			
		

返回例子 (失败):

			
{
    "status": false,
    "message": "Params incorrect"
}
			
		

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

			
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "VND"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$callback_url  = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
	  'username' => $username, 
	  'auth' => $auth, 
	  'amount' => $amount, 
	  'currency' => $currency, 
	  'orderid' => $orderid,
	  'email' => $email, 
	  'phone_number' => $phone_number,
	  'redirect_url' => $redirect_url,
	  'callback_url' => $callback_url
	);
	
$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
    "payment_id": "123456_1_123"
}
			
		

返回例子 (失败):

			
//当客户邮件参数信息错误 
{
    "status": false,
    "message": "email incorrect."
}
			
		

返回例子 (失败):

			
//当参数不齐全
{
    "status": false,
    "message": "Params missing."
}
			
		

返回例子 (失败):

			
//当代理商订单号错误或已存在
{
    "status": false,
    "message": "Order ID Exist."
}
			
		

返回例子 (失败):

			
//当付款数额错误或超过限额
{
    "status": false,
    "message": "Invalid Amount."
}
			
		

返回例子 (失败):

			
//当认证码错误
{
    "status": false,
    "message": "Params incorrect."
}
			
		

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

			
{
    "order_id": "20073",
    "amount": 300.0000,
    "currency": "VND",
    "order_status":"completed",
    "status": true,
    "charge": "9.0000",
    "token":"cb2a91e02770eda1c42d7485f9048913",
    "name":"john doe",
    "type":"deposit",
   
} 
			
		

返回例子(创建订单) - 失败:

			
{
    "order_id": "Example_123",
    "amount": 25.0000,
    "currency": "VND",
    "order_status":"fail",
    "status": true,
    "token":"aZ3423432CWWSDFssdf",
    "charge":"5.00",
    "type":"deposit",
}   
			
		

返回例子(提款) - 成功:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "VND",
    "order_status":"completed",
    "status": true,
    "charge": "5.00",
    "token":"5bf30f18349ce1211fdb0c7aff4d439b",
    "name":"John Doe",
    "type":"withdrawal",
    "remarks":"Success",
}  
			
		

返回例子(提款) - 失败:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "VND",
    "order_status":"fail",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

返回例子(提款) - 拒绝:

			
{
    "order_id": "Testpayout008",
    "amount": 1,
    "currency": "VND",
    "order_status":"rejected",
    "status": true,
    "charge": "0",
    "token":"7fd1297bfc1bd843e9627d09afce0893",
    "name":"SUK THAWAR",
    "type":"withdrawal",
    "remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
			
		

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

提款訂單接口

请求例子:

			
<?php
$auth = "Payment-test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "VND"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$bank_id = "12"; //可从查詢提款銀行列表接口拿到
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字. 
$account_no = "12332343432"; //接收者银行账号
$callback_url = "https://abc.com/withdraw/callback"; //回调地址 (可选)

$send = array(
	  'auth' => $auth,
	  'amount' => $amount,
	  'currency' => $currency,
	  'orderid' => $orderid,
	  'bank_id' => $bank_id,
	  'holder_name' => $holder_name,
	  'account_no' => $account_no,
	  'callback_url' => $callback_url,
	);
	
$apiurl = "https://{Request from us}/merchant/withdraw_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子(成功):

			
{
    "status": true,
    "message": "Success",
    "payment_id": "015459_330_164",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params incorrect",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Params missing.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "bank_id invalid.",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Balance not enough!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Amount Invalid!",
}
			
		

返回例子(失败):

			
{
    "status": false,
    "message": "Order id exist!",
}
			
		

想要在SonicPay創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.

接下來把提款訂單和認證碼發送去提款訂單接口.

查詢提款銀行列表

请求例子:

			
<?php
$username = "Payment-test"; //商户用戶名
$currency = "VND"; //可選的, 货币代号

$send = array(
	  'username' => $username,
	  'currency' => $currency
	);
	
$apiurl = "https://{Request from us}/wallet/withdraw_bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子:

			
{
    "status": true,
    "data": [
        {
            "currency": "VND",
            "bank_name": "Siam Commercial Bank",
            "id": "1"
        },
        {
            "currency": "VND",
            "bank_name": "Siam Commercial Bank",
            "id": "2"
        }
    ]
}
			
		

呼叫提款銀行列表接口來獲取提款銀行列表信息。

查询状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "VND",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "VND",
}
			
		

返回例子 – 有待:

			
{
    "status": true,
    "order_status": "pending",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "VND",
}
			
		

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

查询提款状态接口

请求例子:

			
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户提款订单号

$send = array(
	  'username' => $username,
	  'id' => $id
	);
	
$apiurl = "https://{Request from us}/merchant/check_withdraw_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
			
		

返回例子 – 成功:

			
{
    "status": true,
    "order_status": "completed",
    "order_datetime": "2021-11-18 15:00:00",
    "amount": 300.0000,
    "currency": "VND",
}
			
		

返回例子 – 失败:

			
{
    "status": true,
    "order_status": "fail",
    "order_datetime": "2021-11-19 13:30:00",
    "amount": 25.0000,
    "currency": "VND",
}
			
		

返回例子 – 待定:

			
{
    "status": true,
    "order_status": "proccess",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "VND",
}
			
		

返回例子 – 拒绝:

			
{
    "status": true,
    "order_status": "rejected",
    "order_datetime": "2021-11-20 20:00:00",
    "amount": 100.0000,
    "currency": "VND",
}
			
		

在SonicPay查询提款状态接口,您可以使用Username和ID查询您的提款状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "VND"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。

介绍

正式API接口端点:

        
https://{Request from us}/merchant
        
    

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

        
https://{Request from us}/merchant
        
    

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  6. 您的网页将转接您的客户去SonicPay的付款连接。
  7. 客户将在付款页面选择付款选项然后付款。
  8. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

        
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
        
    

返回例子:

        
{
"status": true,
"rate": [
    {
        "currency": "MYR",
        "min": 420.0000,
        "max": 42000.0000
    },
    {
        "currency": "SGD",
        "min": 134.0000,
        "max": 13400.0000
    }
]
}
        
    

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

        
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
        
    

返回例子:

        
{
"status": true,
"auth": "t5IF5r2fXit1FnhjBVQv"
}
        
    

返回例子 (失败):

        
{
"status": false,
"message": "Params incorrect"
}
        
    

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

        
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "INR"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$pay_method = "UPT"; //其中1个选项 : "UPI", "IMPS"
$callback_url  = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
  'username' => $username, 
  'auth' => $auth, 
  'amount' => $amount, 
  'currency' => $currency, 
  'orderid' => $orderid,
  'email' => $email, 
  'phone_number' => $phone_number,
  'redirect_url' => $redirect_url,
  'pay_method' => $pay_method,
  'callback_url' => $callback_url
);

$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
        
    

返回例子:

        
{
"status": true,
"p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
"payment_id": "123456_1_123"
}
        
    

返回例子 (失败):

        
//当客户邮件参数信息错误 
{
"status": false,
"message": "email incorrect."
}
        
    

返回例子 (失败):

        
//当参数不齐全
{
"status": false,
"message": "Params missing."
}
        
    

返回例子 (失败):

        
//当代理商订单号错误或已存在
{
"status": false,
"message": "Order ID Exist."
}
        
    

返回例子 (失败):

        
//当付款数额错误或超过限额
{
"status": false,
"message": "Invalid Amount."
}
        
    

返回例子 (失败):

        
//当认证码错误
{
"status": false,
"message": "Params incorrect."
}
        
    

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

        
{
"order_id": "20073",
"amount": 300.0000,
"currency": "INR",
"order_status":"completed",
"status": true,
"charge": "9.0000",
"token":"cb2a91e02770eda1c42d7485f9048913",
"name":"john doe",
"type":"deposit",

} 
        
    

返回例子(创建订单) - 失败:

        
{
"order_id": "Example_123",
"amount": 25.0000,
"currency": "INR",
"order_status":"fail",
"status": true,
"token":"aZ3423432CWWSDFssdf",
"charge":"5.00",
"type":"deposit",
}   
        
    

返回例子(提款) - 成功:

        
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "INR",
"order_status":"completed",
"status": true,
"charge": "5.00",
"token":"5bf30f18349ce1211fdb0c7aff4d439b",
"name":"John Doe",
"type":"withdrawal",
"remarks":"Success",
}  
        
    

返回例子(提款) - 失败:

        
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "INR",
"order_status":"fail",
"status": true,
"charge": "0",
"token":"7fd1297bfc1bd843e9627d09afce0893",
"name":"SUK THAWAR",
"type":"withdrawal",
"remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
        
    

返回例子(提款) - 拒绝:

        
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "INR",
"order_status":"rejected",
"status": true,
"charge": "0",
"token":"7fd1297bfc1bd843e9627d09afce0893",
"name":"SUK THAWAR",
"type":"withdrawal",
"remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
        
    

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

提款訂單接口

请求例子:

        
<?php
$auth = "Payment-test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "INR"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$bank_id = "12"; //可从查詢提款銀行列表接口拿到
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字. 
$account_no = "12332343432"; //接收者银行账号
$IFSC_id = "12332343432"; //印度金融系统代码
$callback_url = "https://abc.com/withdraw/callback"; //回调地址 (可选)

$send = array(
  'auth' => $auth,
  'amount' => $amount,
  'currency' => $currency,
  'orderid' => $orderid,
  'bank_id' => $bank_id,
  'holder_name' => $holder_name,
  'account_no' => $account_no,
  'IFSC_id' => $IFSC_id,
  'callback_url' => $callback_url,
);

$apiurl = "https://{Request from us}/merchant/withdraw_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
        
    

返回例子(成功):

        
{
"status": true,
"message": "Success",
"payment_id": "015459_330_164",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "Params incorrect",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "Params missing.",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "bank_id invalid.",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "Balance not enough!",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "Amount Invalid!",
}
        
    

返回例子(失败):

        
{
"status": false,
"message": "Order id exist!",
}
        
    

想要在SonicPay創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.

接下來把提款訂單和認證碼發送去提款訂單接口.

查詢提款銀行列表

请求例子:

        
<?php
$username = "Payment-test"; //商户用戶名
$currency = "INR"; //可選的, 货币代号

$send = array(
  'username' => $username,
  'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/withdraw_bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
        
    

返回例子:

        
{
"status": true,
"data": [
    {
        "currency": "INR",
        "bank_name": "Siam Commercial Bank",
        "id": "1"
    },
    {
        "currency": "INR",
        "bank_name": "Siam Commercial Bank",
        "id": "2"
    }
]
}
        
    

呼叫提款銀行列表接口來獲取提款銀行列表信息。

查询状态接口

请求例子:

        
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
  'username' => $username,
  'id' => $id
);

$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
        
    

返回例子 – 成功:

        
{
"status": true,
"order_status": "completed",
"order_datetime": "2021-11-18 15:00:00",
"amount": 300.0000,
"currency": "INR",
}
        
    

返回例子 – 失败:

        
{
"status": true,
"order_status": "fail",
"order_datetime": "2021-11-19 13:30:00",
"amount": 25.0000,
"currency": "INR",
}
        
    

返回例子 – 有待:

        
{
"status": true,
"order_status": "pending",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "INR",
}
        
    

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

查询提款状态接口

请求例子:

        
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户提款订单号

$send = array(
  'username' => $username,
  'id' => $id
);

$apiurl = "https://{Request from us}/merchant/check_withdraw_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
        
    

返回例子 – 成功:

        
{
"status": true,
"order_status": "completed",
"order_datetime": "2021-11-18 15:00:00",
"amount": 300.0000,
"currency": "INR",
}
        
    

返回例子 – 失败:

        
{
"status": true,
"order_status": "fail",
"order_datetime": "2021-11-19 13:30:00",
"amount": 25.0000,
"currency": "INR",
}
        
    

返回例子 – 待定:

        
{
"status": true,
"order_status": "proccess",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "INR",
}
        
    

返回例子 – 拒绝:

        
{
"status": true,
"order_status": "rejected",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "INR",
}
        
    

在SonicPay查询提款状态接口,您可以使用Username和ID查询您的提款状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "INR"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。

介绍

正式API接口端点:

    
https://{Request from us}/merchant
    

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

    
https://{Request from us}/merchant
    

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  6. 您的网页将转接您的客户去SonicPay的付款连接。
  7. 客户将在付款页面选择付款选项然后付款。
  8. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

    
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"rate": [
{
    "currency": "MYR",
    "min": 420.0000,
    "max": 42000.0000
},
{
    "currency": "SGD",
    "min": 134.0000,
    "max": 13400.0000
}
]
}
    

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

    
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"auth": "t5IF5r2fXit1FnhjBVQv"
}
    

返回例子 (失败):

    
{
"status": false,
"message": "Params incorrect"
}
    

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

    
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "USDT-TRC20"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$callback_url  = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
'username' => $username, 
'auth' => $auth, 
'amount' => $amount, 
'currency' => $currency, 
'orderid' => $orderid,
'email' => $email, 
'phone_number' => $phone_number,
'redirect_url' => $redirect_url,
'callback_url' => $callback_url
);

$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
"payment_id": "123456_1_123"
}
    

返回例子 (失败):

    
//当客户邮件参数信息错误 
{
"status": false,
"message": "email incorrect."
}
    

返回例子 (失败):

    
//当参数不齐全
{
"status": false,
"message": "Params missing."
}
    

返回例子 (失败):

    
//当代理商订单号错误或已存在
{
"status": false,
"message": "Order ID Exist."
}
    

返回例子 (失败):

    
//当付款数额错误或超过限额
{
"status": false,
"message": "Invalid Amount."
}
    

返回例子 (失败):

    
//当认证码错误
{
"status": false,
"message": "Params incorrect."
}
    

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

    
{
"order_id": "20073",
"amount": 300.0000,
"currency": "USDT-TRC20",
"order_status":"completed",
"status": true,
"charge": "9.0000",
"token":"cb2a91e02770eda1c42d7485f9048913",
"name":"john doe",
"type":"deposit",

} 
    

返回例子(创建订单) - 失败:

    
{
"order_id": "Example_123",
"amount": 25.0000,
"currency": "USDT-TRC20",
"order_status":"fail",
"status": true,
"token":"aZ3423432CWWSDFssdf",
"charge":"5.00",
"type":"deposit",
}   
    

返回例子(提款) - 成功:

    
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "USDT-TRC20",
"order_status":"completed",
"status": true,
"charge": "5.00",
"token":"5bf30f18349ce1211fdb0c7aff4d439b",
"name":"John Doe",
"type":"withdrawal",
"remarks":"Success",
}  
    

返回例子(提款) - 失败:

    
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "USDT-TRC20",
"order_status":"fail",
"status": true,
"charge": "0",
"token":"7fd1297bfc1bd843e9627d09afce0893",
"name":"SUK THAWAR",
"type":"withdrawal",
"remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
    

返回例子(提款) - 拒绝:

    
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "USDT-TRC20",
"order_status":"rejected",
"status": true,
"charge": "0",
"token":"7fd1297bfc1bd843e9627d09afce0893",
"name":"SUK THAWAR",
"type":"withdrawal",
"remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}   		
    

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

提款訂單接口

请求例子:

    
<?php
$auth = "Payment-test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "USDT-TRC20"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字. 
$account_no = "TU3Pt7bV51x3no6aoDmcHT88HEvo5SSekT"; //接收者银行账号
$callback_url = "https://abc.com/withdraw/callback"; //回调地址 (可选)

$send = array(
'auth' => $auth,
'amount' => $amount,
'currency' => $currency,
'orderid' => $orderid,
'holder_name' => $holder_name,
'account_no' => $account_no,
'callback_url' => $callback_url,
);

$apiurl = "https://{Request from us}/merchant/withdraw_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子(成功):

    
{
"status": true,
"message": "Success",
"payment_id": "015459_330_164",
}
    

返回例子(失败):

    
{
"status": false,
"message": "Params incorrect",
}
    

返回例子(失败):

    
{
"status": false,
"message": "Params missing.",
}
    

返回例子(失败):

    
{
"status": false,
"message": "bank_id invalid.",
}
    

返回例子(失败):

    
{
"status": false,
"message": "Balance not enough!",
}
    

返回例子(失败):

    
{
"status": false,
"message": "Amount Invalid!",
}
    

返回例子(失败):

    
{
"status": false,
"message": "Order id exist!",
}
    

想要在SonicPay創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.

接下來把提款訂單和認證碼發送去提款訂單接口.

查询状态接口

请求例子:

    
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
'username' => $username,
'id' => $id
);

$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子 – 成功:

    
{
"status": true,
"order_status": "completed",
"order_datetime": "2021-11-18 15:00:00",
"amount": 300.0000,
"currency": "USDT-TRC20",
}
    

返回例子 – 失败:

    
{
"status": true,
"order_status": "fail",
"order_datetime": "2021-11-19 13:30:00",
"amount": 25.0000,
"currency": "USDT-TRC20",
}
    

返回例子 – 待定:

    
{
"status": true,
"order_status": "pending",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "USDT-TRC20",
}
    

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

查询提款状态接口

请求例子:

    
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户提款订单号

$send = array(
'username' => $username,
'id' => $id
);

$apiurl = "https://{Request from us}/merchant/check_withdraw_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子 – 成功:

    
{
"status": true,
"order_status": "completed",
"order_datetime": "2021-11-18 15:00:00",
"amount": 300.0000,
"currency": "USDT-TRC20",
}
    

返回例子 – 失败:

    
{
"status": true,
"order_status": "fail",
"order_datetime": "2021-11-19 13:30:00",
"amount": 25.0000,
"currency": "USDT-TRC20",
}
    

返回例子 – 待定:

    
{
"status": true,
"order_status": "proccess",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "USDT-TRC20",
}
    

返回例子 – 拒绝:

    
{
"status": true,
"order_status": "rejected",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "USDT-TRC20",
}
    

在SonicPay查询提款状态接口,您可以使用Username和ID查询您的提款状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "USDT-TRC20"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。

介绍

正式API接口端点:

    
https://{Request from us}/merchant
    

欢迎使用SonicPay API应用接口! 您可以使用我们的API应用接口来创建付款订单。

我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。

测试环境

测试API接口端点:

    
https://{Request from us}/merchant
    

SonicPay测试服务器功能将会以正式服务器相同,除了部分功能.

提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.

API 流程

正常完整流程
  1. 客户登入您的网站
  2. 客户选择商品/费用创建消费订单
  3. 您的资料库内创建订单资料(ID,费用信息)。
  4. 使用auth api(认证码接口) 来获取新的认证码。
  5. 发送订单资料去generate_orders api(创建订单接口),SonicPay将返回付款连接URL。
  6. 您的网页将转接您的客户去SonicPay的付款连接。
  7. 客户将在付款页面选择付款选项然后付款。
  8. 成功付款后SonicPay将会发送付款成功信息去您的callback接口

货币接口

请求例子:

    
<?php
$username = "Payment-test"; //商户用戶名 
$send = array('username' => $username );
$apiurl = "https://{Request from us}/merchant/currency";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"rate": [
{
    "currency": "MYR",
    "min": 420.0000,
    "max": 42000.0000
},
{
    "currency": "SGD",
    "min": 134.0000,
    "max": 13400.0000
}
]
}
    

使用这个接口功能,你将会得到SonicPay能接受货币付款限额的返回资料

认证码接口

请求例子:

    
<?php
$username = "Payment-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{Request from us}/merchant/auth";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"auth": "t5IF5r2fXit1FnhjBVQv"
}
    

返回例子 (失败):

    
{
"status": false,
"message": "Params incorrect"
}
    

当使用generate_orders(创建订单接口)时需要认证码。

您可以使用您的API_key和Username(代理商账号)放送去认证码接口来得到认证码返回信息。

Api_key 可以在您的账号设定页上找到。

创建订单接口

请求例子:

    
<?php
$username = "john"; //客戶用戶名
$auth = "t5IF5r2fXit1FnhjBVQv"; //认证码(可从认证码接口拿到)
$amount = 100; //付款数额
$currency = "MYR"; //货币代号
$orderid = "Example_123"; //商户订单号
$email = "[email protected]"; //客户邮件账号
$phone_number = "601012456789"; //客户手机号码
$redirect_url = "https://www.google.com"; //重导链接
$pay_method = "online_banking2";; //online_banking2而已
$bank_id = "96"; //银行号
$callback_url  = "https://abc.com/deposit/callback"; //回调地址 (可选)

$send = array(
'username' => $username, 
'auth' => $auth, 
'amount' => $amount, 
'currency' => $currency, 
'orderid' => $orderid,
'email' => $email, 
'phone_number' => $phone_number,
'redirect_url' => $redirect_url,
'pay_method' => $pay_method,
'bank_id' => $bank_id,
'callback_url' => $callback_url
);

$apiurl = "https://{Request from us}/merchant/generate_orders";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子:

    
{
"status": true,
"p_url": "https://xxxxx.com/checkout/order-pay/92/?pay_for_order=true&key=1234"
"payment_id": "123456_1_123"
}
    

返回例子 (失败):

    
//当客户邮件参数信息错误 
{
"status": false,
"message": "email incorrect."
}
    

返回例子 (失败):

    
//当参数不齐全
{
"status": false,
"message": "Params missing."
}
    

返回例子 (失败):

    
//当代理商订单号错误或已存在
{
"status": false,
"message": "Order ID Exist."
}
    

返回例子 (失败):

    
//当付款数额错误或超过限额
{
"status": false,
"message": "Invalid Amount."
}
    

返回例子 (失败):

    
//当认证码错误
{
"status": false,
"message": "Params incorrect."
}
    

想要在SonicPay创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。

接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。

Callback接口

返回例子(创建订单) - 成功:

    
{
"order_id": "20073",
"amount": 300.0000,
"currency": "MYR",
"order_status":"completed",
"status": true,
"charge": "9.0000",
"token":"cb2a91e02770eda1c42d7485f9048913",
"name":"john doe",
"type":"deposit",

} 
    

返回例子(创建订单) - 失败:

    
{
"order_id": "Example_123",
"amount": 25.0000,
"currency": "MYR",
"order_status":"fail",
"status": true,
"token":"aZ3423432CWWSDFssdf",
"charge":"5.00",
"type":"deposit",
}   
    

客户完成付款后,SonicPay将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。

备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认

查詢存款銀行列表

请求例子:


<?php
$username = "Payment-test"; //商户用戶名
$currency = "MYR"; //可選的, 货币代号

$send = array(
'username' => $username,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/bank_list";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子:


{
"status": true,
"data": [
{
"currency": "MYR",
"bank_name": "Affin Bank Berhad",
"id": "1"
},
{
"currency": "MYR",
"bank_name": "AmBank (M) Berhad",
"id": "2"
}
]
}

呼叫存款銀行列表接口來獲取存款銀行列表信息。

查询状态接口

请求例子:

    
<?php
$username = "john"; //商户用戶名
$id = "Example_123"; //商户订单号

$send = array(
'username' => $username,
'id' => $id
);

$apiurl = "https://{Request from us}/merchant/check_status";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
    

返回例子 – 成功:

    
{
"status": true,
"order_status": "completed",
"order_datetime": "2021-11-18 15:00:00",
"amount": 300.0000,
"currency": "MYR",
}
    

返回例子 – 失败:

    
{
"status": true,
"order_status": "fail",
"order_datetime": "2021-11-19 13:30:00",
"amount": 25.0000,
"currency": "MYR",
}
    

返回例子 – 待定:

    
{
"status": true,
"order_status": "pending",
"order_datetime": "2021-11-20 20:00:00",
"amount": 100.0000,
"currency": "MYR",
}
    

在SonicPay查询状态接口,您可以使用Username和ID查询您的订单状态。

余额接口

请求例子:


<?php
$auth = "skcblasjkcb"; //从认证码获取
$currency = "MYR"; 

$send = array(
'auth' => $auth,
'currency' => $currency
);

$apiurl = "https://{Request from us}/wallet/get_balance";

$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 400); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $send);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data"));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

返回例子


{
"status": true,
"balance": "0.00",
}

允许用户查看他们当前的钱包余额。它会以指定的货币显示余额,提供实时且准确的可用资金概。