# Merchant scan barcode

This document is for offline merchant, eg. restaurant, supermarket, retailer etc. Merchant scan user's barcode or qrcode(Alipay,Wechat or UnionPay) to launch payment.

# Request URL

Endpoint: https://api.iotpaycloud.com/v1/create_order

Request method:

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

# Parameters

name required type sample description
mchId y String(30) 20001222 merchant id assigned by IOTPay
mchOrderNo y String(30) 20160427210604000490 order id assigned by merchant
need to be unique
channelId y String WX_MICROPAY or
ALIPAY_MICROPAY
only support these two options
currency y String(3) CAD 3 letter representation for currency,eg:CAD
amount y int 100 payment amount in cents,eg. $28.65 is 2865
clientIp y String(32) 210.73.10.148 client ip
device y String(64) V1-B18 The type of the scaning device
deviceId y String(64) V102219391901 The ID of the scaning device
notifyUrl y String(200) http://xxx.com/notify.php need to pass this value,but not used for now
subject y String(64) product1 product title
body y String(256) this product is good product description
codeType y String(64) "barcode" Fill in "barcode" here
identityCode y String(64) 352645673847987656 Personal payment code number
obtained by scanning
extra n String(512) {"productId":"100005761557771065",
"pos_flag":"yes"}
jobNo y String(50) merchant login name
remarks n String(200) remarks
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 signature

# parameter sample

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"}

# return result

Variable name Required Type Sample value Description
retCode Yes String SUCCESS SUCCESS/FAIL,This field is the communication identifier,
not transaction identifier. You need to check the resCode to see if the transaction is successful.
retMsg No String Signature Failed The returned information is the cause of the error if not blank.
Signature failure or parameter format verification error

The following fields are returned when retCode is SUCCESS

Variable name Required Type Sample value Description
resCode Yes String SUCCESS SUCCESS/FAIL
errCode No String SYSTEMERROR Error code
errCodeDes No String SYSTEMERROR Description of returned information

# sample return result

{"errCodeDes":"call wechat pay failed::101 invalid barcode,please re-scan","errCode":"AUTH_CODE_INVALID","sign":"3E42B17C9C0F8F9DC8AF145171295E28","resCode":"FAIL","retCode":"SUCCESS","retMsg":""}

{"errCodeDes":"merchant signature error","errCode":"0001","resCode":"FAIL","retCode":"FAIL","retMsg":"SOUNDWAVE_PARSER_FAIL"}

# polling order status

Even retCode and resCode are both SUCCESS, it doesn't mean user has finished the payment successfully. You still need to check status value, if the status = 2 or 3, it means the transaction is successful. Or else you need to use order query to poll the order status, eg, query status per 2 seconds, the max retry time can be 30. If the status is not success in one minute, you can deem the transaction failed.

# order status

0: created but not paid
1: user is paying, e.g. user is typing password
2: paid
3: paid and notified the merchant(if notifyUrl used)
4: cancelled by system
9: cancelled by user
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.

# error code

more error code

# demo and source code

Demo

Source code

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