# App integrate IOTPay

# Basic process

There are four roles in the whole integration:

1, Merchant App
2, Merchant backend server
3, IOTPay API server
4, Wechat pay and Alipay server

Merchant App send payment request to IOTPay API server, IOTPay API return the encrypted data to the merchant app, then merchant app send the encrypted data to Alipay/Wechat pay server via SDK. IOTPay API server will notify merchant backend server when the transaction is successful.

An image

# Merchant App call merchant backend server api

The API is defined by merchant,can use the followint as reference:

Server address: https://merchant_server/pay?channelid=XXX&amount=xxx

  • Request method: GET

Merchant backend server call create order api of IOTPay, after get the request from merchant app.

# for app integration, channel should be :

Channel ID Channel Name
WX_APP wechat pay
ALIPAY_MOBILE alipay

# merchant backend call create order api

# request URL

Server address: https://pay.4jicao.com/api/pay/create_order

Request method:

  • POST
  • Content-Type: application/x-www-form-urlencoded

An image

# parameters

name required type sample description
mchId y String(30) 10000701 merchant id assigned by IOTPay
mchOrderNo y String(30) 20160427210604000490 order number in merchant system,need to be unique
channelId y String(24) ALIPAY_MOBILE ALIPAY_MOBILE OR WX_APP
currency y String(3) CAD 3 letters representation for currency
amount y int 100 payment amount,in cents,eg. $28.56 is 2856
clientIp y String(32) 210.73.10.148 Client IP
device n String(64) WEB device identifier
notifyUrl y String(200) http://xxx.com/notify.php IOTPay will notify this url when payment success
subject y String(64) product id or title product id or title
body y String(256) product description product description
param1 n String(64) IOTPay will send back the original value
param2 n String(64) IOTPay will send back the original value
extra n String(512)
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 signature

# php sample code

$url = 'https://pay.4jicao.com/api/pay/create_order';
$channelId    = $_REQUEST['channelid'];
$order_amount = $_POST['orderamount'];

$order_sn = $_SERVER['REQUEST_TIME'];
$Utility = new Utility();
$ip = $Utility->real_ip();
$notifyUrl = 'https://develop.IOTPay.ca/demo/order/notify.php';
$subject = 'test';
$body = 'paytest';


$arr = array(
    'mchId' => $merchant_id,
    'mchOrderNo' => $order_sn,
    'extra' => '',
    'channelId' => $channelId,
    'currency' => 'CAD',
    'amount' => intval($order_amount * 100),
    'clientIp' => $ip,
    'device' => 'WEB',
    'notifyUrl' => $notifyUrl,
    'subject' => $subject,
    'body' => $body,
);
$sort_array = $Utility->arg_sort($arr);
$arr['sign'] = $Utility->build_mysign($sort_array, $merchant_key, "MD5");//Generate signature parameter sign
$param = 'params=' . json_encode($arr);
$resBody = $Utility->request($url, $param);//Submit to the gateway
$res = json_decode($resBody, true);
if($channelId =='WX_APP')
{
	echo $resBody;
}
else if ($channelId =='ALIPAY_MOBILE')
{
    echo $res['payParams'];
}

# error code

more error code

# Wechat/Alipay SDK and Documents:

# Demo source code

download

Last Updated: 11/20/2019, 2:59:46 PM