Latest update time:2020.04.30 Release notes
Merchants call wx.requestPayment(OBJECT) in the Mini Program to start WeChat Pay.
Applicable object:Common modeInstitutional mode
API Rules: https://wechatpay-api.gitbook.io/wechatpay-api-v3
Name | Variable Name | Type | Required | Description |
---|---|---|---|---|
Mini Program id | appId | String(16) | Yes | The merchant can get it after registering a Mini Program successfully. Example:wx8888888888888888 |
Timestamp | timeStamp | String(32) | Yes | The current time. For details, see timestamp rules. Example:1414561699 |
Random string | nonceStr | String(32) | Yes | Random string, not longer than 32 digits. It is recommended to use the random number generation algorithm. Example:5K8264ILTKCH16CQ2502SI 8ZNMTM67VS |
An extension string for order details | package | String(128) | Yes | The value of the prepay_id parameter returned by the unified order placement API, in the format of prepay_id=*** Example:prepay_id=123456789 |
Signature fields and formats:
Mini Program id
Timestamp
Random string
An extension string for order details
Example of a string to be signed:
wx8888888888888888
1414561699
5K8264ILTKCH16CQ2502SI8ZNMTM67VS
prepay_id=123456789
Calculating signature value
The signature method is the same as the signature for request data. Use the merchant private key to sign the string using the SHA256-with-RSA signature algorithm, and obtain the signature value through Base64 encoding.
Object parameter description:
Name | Variable Name | Type | Required | Description |
---|---|---|---|---|
TimeStamp | timeStamp | String(32) | Yes | The current time. For details, see timestamp rules. Example:1990840662 |
NonceStr | nonceStr | String(32) | Yes | Random string, not longer than 32 digits. Example:5K8264ILTKCH16CQ2502SI8ZNMTM67VS |
Package | package | String(128) | Yes | The value of the prepay_id parameter returned by the order placement API, in the format of prepay_id=* Example:prepay_id=12345678 |
SignType | signType | String(32) | Yes | Signature type. Default is RSA. This parameter is not used in the signature. Example:RSA |
PaySign | paySign | String(64) | Yes | Signature. For more information, see the paySign generation rules. Example:UGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg== |
Callback Type | errMsg | DescriptionCallback results: |
---|---|---|
success | requestPayment:ok | Calling payment successful |
fail | requestPayment:fail cancel | User cancels payment |
fail | requestPayment:fail (detail message) | Failed to call payment. The detail message is the specific failure reason returned by the backend. |
wx.requestPayment(
{
"timeStamp": "1414561699",
"nonceStr": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS",
"package": "prepay_id=wx201410272009395522657a690389285100",
"signType": "RSA",
"paySign": "UGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==",
'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证