# wx.requestOrderPayment(Object args)
Start from base library version 2.16.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Not supported
Create custom transaction component order and initiate payment.
Only connectedCustom Version Transaction Component的小程序需要使用,普通小程序可直接使用 wx.requestPayment
。
# parameter
# Object args
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
timeStamp | string | yes | Timestamp, from 1970 year 1 Moon 1 day 00:00:00 Number of seconds to date, the current time | |
nonceStr | string | yes | A random string of 32 characters or less in length | |
package | string | yes | Unified single interface returns prepay_id Parameter values in the format of prepay_id=*** | |
paySign | string | yes | Signature, see WeChat payment documents | |
orderInfo | Object | no | Order information, to be passed only in scenarios where validation is required, seeInterface Dxplaination | |
extUserUin | string | no | External APP User ID | |
signType | string | MD5 | no | Signature algorithm, should be consistent with the value of the background order |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
args.signType Legal value
value | Introductions | Minimum version |
---|---|---|
MD5 | Only in v2 Version Interface | |
HMAC-SHA256 | Only in v2 Version Interface | |
RSA | Only in v3 Version Interface |
# sample code
// except orderInfo The remaining fields correspond to the wx.requestPayment Agreement
wx.requestOrderPayment({
orderInfo: {},
timeStamp: '',
nonceStr: '',
package: '',
signType: 'MD5',
paySign: '',
success (res) { },
fail (res) { }
})
# Pre-check
Access to the custom version of the transaction components, to initiate WeChat payment, please checkScenarios requiring validation。 In the scenario that requires verification, the interface must be used when initiating WeChat payment, and the relevantOrder information进行校验,校验通过后用户才可以完成当前订单的支付,非需要校验的场景则可以按照商家要求自行选择传入订单信息或不传入。