WeChat Mini Program

This endpoint requires the merchant to have a pre-existing WeChat Mini Program that is registered under a non-Chinese company.

API Request

Endpoint

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

Method

POST

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

Parameters

NameRequiredTypeSampleDescription
mchIdyString(30)10000701merchant ID assigned by IOTPay
mchOrderNoyString(30)20160427210604000490order number in merchant system, need to be unique
channelIdyString(24)WX_JSAPIFixed to WX_JSAPI
currencyyString(3)CAD3 letters representation for currency
amountyint100payment amounts, in cents, e.g. $28.56 is 2856
clientIpyString(32)210.73.10.148Client IP
devicenString(64)WEBdevice identifier
notifyUrlyString(200)http://xxx.com/notify.phpIOTPay will notify this URL when payment success
subjectyString(64)product ID or titleproduct ID or title
bodyyString(255)product descriptionthe description of the product
param1nString(64)IOTPay will send back the original value
param2nString(64)IOTPay will send back the original value
extrayString(512){"openId":"o2R****eaDqo", "type":"minipay","appId":"xxxxxxxxx"}
jobNoyString(50)merchant login name
remarksnString(200)remarks
signyString(32)C380BEC2BFD727A4B6845133519F3AD6signature

When merchant get the response from IOTPay API, pass the returned parameters to mini program. Mini program will call wx.requestPayment with these parameters.

wx.requestPayment({
  appId: res.data.payParams.appId,
  timeStamp: res.data.payParams.timeStamp,
  nonceStr: res.data.payParams.nonceStr,
  package: res.data.payParams.package,
  signType: res.data.payParams.signType,
  paySign: res.data.payParams.paySign,
  success(res) {
    console.log(res)
    wx.navigateTo({
      url: '',
    })
  },
  fail(res) {
    console.log(res)
    wx.navigateTo({
      url: '',
    })
  },
})

After payment, merchant backend server still need notifyUrl to judge whether the transaction is successful

Return Fields

NameRequiredTypeSampleDescription
retCodeyString(16)SUCCESSSUCCESS/FAIL this field indicate communication result, not transaction.
Need to check resCode to see whether transaction succeed
retMsgnString(128)signature errorerror message

The following fields will return when retCode and resCode are both SUCCESS

NameRequiredTypeSampleDescription
payOrderIdyStringpayment order ID
payParamsyArraythe parameters for mini program to call wx.requestPayment
signyStringsignature

Error Code

more error code

Sample Code

sample code downloadopen in new window

Last Updated: