介绍
正式API接口端点:
https://{request from us}/merchant
欢迎使用Vpay88 API应用接口! 您可以使用我们的API应用接口来创建付款订单。
我们的API是使用Form-data来作为请求方式,返回的数据将会是JSON模式(包括错误返回)。
测试环境
测试API接口端点:
https://{request from us}/merchant
Vpay88测试服务器功能将会以正式服务器相同,除了部分功能.
提醒:在与正式环境API做对接前,最好能先在测试环境上尝试连接看是否能得到与正式服务器的结果一样.
API 流程
正常完整流程
- 客户登入您的网站
- 客户选择商品/费用创建消费订单
- 您的资料库内创建订单资料(ID,费用信息)。
- 使用auth api(认证码接口) 来获取新的认证码。
- 发送订单资料去generate_orders api(创建订单接口),Vpay88将返回付款连接URL。
- 您的网页将转接您的客户去Vpay88的付款连接。
- 客户将在付款页面选择付款选项然后付款。
- 成功付款后Vpay88将会发送付款成功信息去您的callback接口。
货币接口
请求例子:
<?php
$username = "vpay88-test"; //商户用戶名
$send = array('username' => $username );
$apiurl = "https://{request from us}/merchant/currency";
$curl = curl_init($url);
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
}
]
}
使用这个接口功能,你将会得到Vpay88能接受货币付款限额的返回资料
认证码接口
请求例子:
<?php
$username = "vpay88-test"; //商户用戶名
$api_key = "EPSOWM0eewwrwer0OfUo"; //API_key 可以在您的账号设定页上找到
$send = array('username' => $username , 'api_key' => $api_key);
$apiurl = "https://{request from us}/merchant/auth";
$curl = curl_init($url);
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"; //客户手机号码
$mode = "DIGI"; //可選的, 只適用於部分使用預付卡付款的代理商。選項:DIGI,MAXIS,CELCOM
$redirect_url = "https://www.google.com"; ///可選的, 讓需要使用不同的重導鏈接僅可
$send = array(
'username' => $username,
'auth' => $auth,
'amount' => $amount,
'currency' => $currency,
'orderid' => $orderid,
'email' => $email,
'phone_number' => $phone_number,
'mode' => $mode,
'redirect_url' => $redirect_url
);
$apiurl = "https://{request from us}/merchant/generate_orders";
$curl = curl_init($url);
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"
}
返回例子 (失败):
//当客户邮件参数信息错误
{
"status": false,
"message": "email incorrect."
}
返回例子 (失败):
//当参数不齐全
{
"status": false,
"message": "Params missing."
}
返回例子 (失败):
//当货币参数错误
{
"status": false,
"message": "Currency invalid."
}
返回例子 (失败):
//当代理商订单号错误或已存在
{
"status": false,
"message": "Order ID Exist."
}
返回例子 (失败):
//当付款数额错误或超过限额
{
"status": false,
"message": "Invalid Amount."
}
返回例子 (失败):
//当认证码错误
{
"status": false,
"message": "Params incorrect."
}
想要在Vpay88创建订单,首先需要在您的资料库创建个订单资料然后使用认证码接口拿到新的认证码。
接下来把订单资料和认证码放送去创建订单接口以得到付款连接的返回。
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",
}
返回例子(提款) - 成功:
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "MYR",
"order_status":"completed",
"status": true,
"charge": "5.00",
"token":"5bf30f18349ce1211fdb0c7aff4d439b",
"name":"John Doe",
"type":"withdrawal",
"remarks":"Success",
}
返回例子(提款) - 失败:
{
"order_id": "Testpayout008",
"amount": 1,
"currency": "MYR",
"order_status":"fail",
"status": true,
"charge": "0",
"token":"7fd1297bfc1bd843e9627d09afce0893",
"name":"SUK THAWAR",
"type":"withdrawal",
"remarks":"Account Holder Name Mismatch (MR SUK THA != SUK THAWAR)",
}
客户完成付款后,Vpay88将会以JSON资料放送一个POST请求去您的账号页设定的callback接口。
备注:令牌将会使用MD5("密钥" + 代理商订单号)来做检查确认
提款訂單接口
请求例子:
<?php
$auth = "vpay88_test"; //认证码(从认证码接口拿到)
$amount = 100; //提款数额
$currency = "MYR"; //货币代号
$orderid = "Example_123"; //商户提款订单号
$bank_id = "12"; //可从查詢提款銀行列表接口拿到
$bank_branch = "Kentucky"; //可選的
$holder_name = "John Doe"; //接收者持有人名字一定要和接收银行账号相同名字.
$account_no = "12332343432"; //接收者银行账号
$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,
);
$apiurl = "https://{request from us}/merchant/withdraw_orders";
$curl = curl_init($url);
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",
}
返回例子(失败):
{
"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!",
}
想要在Vpay88創建提款訂單,首先需在您的資料庫創建個提款訂單然後使用認證碼接口#2拿到新的認證碼.
接下來把提款訂單和認證碼發送去提款訂單接口.
查詢提款銀行列表
请求例子:
<?php
$username = "vpay88_test"; //商户用戶名
$currency = "MYR"; //可選的, 货币代号
$send = array(
'username' => $username,
'currency' => $currency
);
$apiurl = "https://{request from us}/wallet/withdraw_bank_list";
$curl = curl_init($url);
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": "Malayan Banking Berhad",
"id": "1"
},
{
"currency": "MYR",
"bank_name": "Malayan Banking 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($url);
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",
}
在Vpay88查询状态接口, ,您可以使用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($url);
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",
}
在Vpay88查询提款状态接口, ,您可以使用Username和ID查询您的提款状态。