商户App集成IOTPay

基本流程

在App集成场景下,有4个参与的系统:

1, 商家的App
2, 商家的后台系统
3, IOTPay的API服务
4, 微信支付/支付宝/银联的服务

对于商户APP,商户发送支付请求到支付中心后,支付中心向商户返回加密数据且不向三方支付发送消息。商户利用接收到的加密数据调用三方支付的SDK,向三方支付发起支付请求。当支付中心收到三方支付 的支付消息后,支付中心通知商户支付结果。

An image

商家App调用商家后台API

该API由商家自行定义,可参考的基本例子如下:

服务地址: https://merchant_server/pay?channelid=XXX&amount=xxx

  • 请求方式: GET

商家后台收到App调用后,向IOTPay发起下单。

App支付需指定ChannelId如下:

渠道ID渠道名称
WX_APP商户APP微信支付
ALIPAY_MOBILE商户APP支付宝支付
UPI_APP银联SecurePay

商家后台调用统一下单接口

请求URL

服务地址: https://api.iotpaycloud.com/v1/create_order

请求方式:

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

An image

参数说明

字段名变量名必填类型示例值描述
商户IDmchIdString(30)10000701支付中心分配的商户号
商户订单号mchOrderNoString(30)20160427210604000490商户生成的订单号,请保证唯一性
渠道IDchannelIdString(24)ALIPAY_MOBILE支付渠道参数
币种currencyString(3)CAD三位货币代码,加币:CAD
支付金额amountint100支付金额,单位分
客户端IPclientIpString(32)210.73.10.148客户端IP地址
设备deviceString(64)WEB终端设备号(门店号或收银设备ID),注意:PC网页或公众号内支付请传"WEB"
支付结果回调URLnotifyUrlString(200)http://xxx.com/notify.php支付结果回调URL
商品主题subjectString(64)测试商品商品主题
商品描述信息bodyString(255)xxpay测试商品描述商品描述信息
扩展参数1param1String(64)支付中心回调时会原样返回
扩展参数2param2String(64)支付中心回调时会原样返回
附加参数extraString(512){"type":"apppay","appId":"xxxxxxxxx"}appId从微信开放平台获取
子账号jobNoString(50)商户登录名
附言remarksString(200)商户的附言
签名signString(32)C380BEC2BFD727A4B6845133519F3AD6签名值,详见签名算法

微信App支付(WX_APP)

提示

您可以在微信开放平台在新窗口打开注册一个账号并登记您的应用程序来获得您的appId

字段名变量名必填类型示例值描述
附加参数extraJSON{"type":"apppay","appId":"xxxxxxxxx"}

支付宝App支付(ALIPAY_MOBILE) 或者 UPI_APP(银联SecurePay)

字段名变量名必填类型示例值描述
附加参数extraJSON该参数不用传

php代码示例


require_once('Utility.php');

$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);
echo json_encode($res['payParams']); //client app use payParams to call sdk


微信/支付宝的SDK和文档:

Demo源码

源码下载 下载在新窗口打开

上次更新: