# 商户扫码支付

此文档适用于在商户扫描用户的微信,支付宝的条码或银联云闪付二维码的支付方式。 主要应用场景是线下餐饮门店,零售商超等。

# 请求URL

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

请求方式:

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

# 参数说明

字段名 变量名 必填 类型 示例值 描述
商户ID mchId String(30) 20001222 支付中心分配的商户号
商户订单号 mchOrderNo String(30) 20160427210604000490 商户生成的订单号
请保证唯一性
支付通道 channelId String WX_MICROPAY or
ALIPAY_MICROPAY
only support these two options
币种 currency String(3) CAD 三位货币代码,加币:CAD
支付金额 amount int 100 支付金额,单位分
客户端IP clientIp String(32) 210.73.10.148 客户端IP地址
设备 device String(64) V1-B18 The type of the scaning device
设备Id deviceId String(64) V102219391901 The ID of the scaning device
支付结果回调URL notifyUrl String(200) http://xxx.com/notify.php 支付结果回调URL,需要传值,但是没有notify
商品主题 subject String(64) 测试商品 商品主题
商品描述信息 body String(255) xxpay测试商品描述 商品描述信息
条码类型 codeType String(64) "barcode" Fill in "barcode" here
条码值 identityCode String(64) 352645673847987656 Personal payment code number
obtained by scanning
附加参数 extra String(512) {"productId":"100005761557771065",
"pos_flag":"yes"}
子账号 jobNo String(50) 商户登录名
附言 remarks String(200) 商户的附言
签名 sign String(32) C380BEC2BFD727A4B6845133519F3AD6 签名值,详见签名算法

# 参数示例

params={"mchId":"10000576","mchOrderNo":1557771065,"extra":"{\"productId\":\"100005761557771065\",\"pos_flag\":\"yes\"}","channelId":"WX_MICROPAY","currency":"CAD","amount":1,"clientIp":"207.216.193.72","notifyUrl":"http:\/\/localhost\/testtool\/test\/notify.php","subject":"test","body":"paytest","device":"V1-B18","deviceId":"V102174C02773","codeType":"barcode","identityCode":"352645673847987656""sign":"DF1B222C8A482231E485DAA3D1A8F685"}

# 返回结果

Variable name Required Type Sample value Description
retCode Yes String SUCCESS SUCCESS/FAIL,either retCode or resCode is FAIL, the transaction failed
resCode Yes String SUCCESS SUCCESS/FAIL,either retCode or resCode is FAIL, the transaction failed
retMsg No String Signature Failed The returned information is the cause of the error if not blank.
Signature failure or parameter format verification error
payOrder No JSON order detail if resCode and retCode are SUCCESS, payOrder will be returned

The following fields are returned in payOrder:

Variable name Required Type Sample value Description
payOrderId Yes String 'AM20210727205735526962718926' unique pay order id assigned by IOT Pay
mchOrderNo Yes String '1627419455' unique pay order id assigned by merchant
status Yes Int 2 2 or 3 means transaction success
## 轮询订单状态
即使retCode和resCode返回SUCCESS,并不能保证用户已经成功支付。商户需要判断返回的status字段值,如果status=2或3,表示订单成功。
否则的话,需要使用 [order query](/zh/orderquery.md) 发起轮询确保订单状态成功。例如,每2秒钟查询订单状态一次,最多查30次。

## order status
0:  created but not paid<br>
1:  user is paying, e.g. user is typing password<br>
2:  paid<br>
3:  paid and notified the merchant(if notifyUrl used)<br>
4:  cancelled by system<br>
9:  cancelled by user<br>
when polling order status, only 2 or 3 is success, if status > 3,  the order won't be success again, the polling can be stopped.



## 商户扫码测试

测试 [点击这里](https://develop.IOTPay.ca/newdemo/scan/demo.html) 

源码 [点击这里](https://develop.IOTPay.ca/newdemo/scan.tar.gz)
上次更新: 7/27/2021, 3:02:32 PM