# 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

# merchant backend call create order api

# request URL

Endpoint: https://api.iotpaycloud.com/v1/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
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) 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 y String(512) {"type":"apppay","appId":"xxxxxxxxx"} wechat mini program,WX_APP,WX_APP need this
jobNo y String(50) merchant login name
remarks n String(200) remarks
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 signature

# Wechat App(WX_APP)

| extra | y | JSON | {"type":"apppay","appId":"xxxxxxxxx"} | |


| extra | n | JSON | ignore this parameter | |

# php sample code


$url = 'http://api.iotpaycloud.com/v1/create_order';
$merchantId  = '1000####';
$merchantKey = '#############################';

$channelId  = $_REQUEST['channelid'];
$orderAmount = $_REQUEST['amount'];

$orderNo = $_SERVER['REQUEST_TIME'];

$Utility = new Utility();
$ip = $Utility->real_ip();
$notifyUrl = 'https://develop.iotpay.ca/demo/order/notify.php';
$subject = 'test';
$body = 'paytest';

$extra = '';
if($channelId =='WX_APP')
  $appId  = 'wxxxxxxxxxxxxxx';
  $type = 'apppay';
  $extra = json_encode(array(
    'type' => $type,
    'appId' => $appId,

$arr = array(
    'mchId' => $merchantId,
    'mchOrderNo' => $orderNo,
    'extra' => $extra,
    'channelId' => $channelId,
    'currency' => 'CAD',
    'amount' => intval($orderAmount * 100),
    'clientIp' => $ip,
    'device' => 'WEB',
    'notifyUrl' => $notifyUrl,
    'subject' => $subject,
    'body' => $body,


$sortArray = $Utility->arg_sort($arr);

$arr['sign'] = $Utility->build_mysign($sortArray, $merchantKey, "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


Last Updated: 7/2/2020, 10:40:51 AM