Latest update time:2019.11.20 Release notes
API for calling payment from mini program frontend
Applicable object: Common modeInstitutional mode
The fields for generating signature when calling payment in Mini Program:
Name | ID | Type | Required | Description |
---|---|---|---|---|
Mini Program ID | appId | String(16) | Yes | This ID is issued after merchants apply for Mini Program, it should be the one which calls payment. Example:wx8888888888888888 |
Timestamp | timeStamp | String(32) | Yes | Specifies the current time. For more information, see Timestamp in Parameter Specifications. |
Random String | nonceStr | String(32) | Yes | 32 characters or fewer. For more information, see Random String Algorithm. Example:5K8264ILTKCH16CQ2502SI8ZNMTM67VS |
Order Extension String | package | String(128) | Yes | Specifies the parameter value (prepay_id) returned by the Unified Order API. The submission format is "prepay_id=***". Example:prepay_id=123456789 |
Sign type | signType | String(32) | Yes | Currently HMAC-SHA256 and MD5 are supported, default is MD5. This parameter must be submitted if HMAC-SHA256 is chosen Example:MD5 |
Example:
paySign = MD5(appId=wxd678efh567hg6787&nonceStr= 5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id= wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key= qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6
Please refer to 【Section Signature Algorithm】 for more information.
Call function wx.requestPayment(OBJECT) to load payment.
Please refer to the description for parameter OBJECT:
Parameter | Type | Required | Description |
---|---|---|---|
timeStamp | String | Yes | Specifies the current time. For more information, see Timestamp in Parameter Specifications. |
nonceStr | String | Yes | 32 characters or fewer. |
package | String | Yes | Specifies the parameter value (prepay_id) returned by the Unified Order API. The submission format is "prepay_id=***". |
signType | String | Yes | MD5 or HMAC-SHA256 |
paySign | String | Yes | Signature generated with the above parameters |
success | Function | No | Callback function if calls successfully |
fail | Function | No | Callback function if calls failed |
complete | Function | No | Callback function when calling complete (execute both when success and fail) |
Field Name | Return Value | Description |
---|---|---|
success | requestPayment:ok | Calling payment is successful. |
fail | requestPayment:fail cancel | Payment is cancelled by customer. |
fail | requestPayment:fail (detail message) | Calling payment is failed, the detailed information can be found in parameter value: detail message |
wx.requestPayment(
{
'timeStamp': '1414561699',
'nonceStr': '5K8264ILTKCH16CQ2502SI8ZNMTM67VS',
'package': 'Sign=WXPay',
'signType': 'MD5',
'paySign': 'C380BEC2BFD727A4B6845133519F3AD6',
'success':function(res){},
'fail':function(res){},
'complete':function(res){}
})
Customer Service Tel
Business Development
9:00-18:00
Monday-Friday GMT+8
Technical Support
WeChat Pay Global
ICP证