# 6. Wechat Calls Payment Reference
only for Mini Program Payment and App Payment
# Wechat Mini Program Payment
The merchant first calls the WebPay Create to generate a prepayment order, and obtain the metadata.wechatpay before transferring it to the app to initiate payment.
Then the merchant calls
wx.requestPayment(OBJECT)
in the Mini Program to start WeChat Pay. Wechat Official Doc (opens new window)with Promise style call: Supported
Mini Program plugin: Not supported
Wechat Windows version: Supported
Wechat Mac version: Supported
# Request Parameters
parameter name | required | type of data | description |
---|---|---|---|
timeStamp | Yes | string | timestamp, get it from metadata.wechatpay.timeStamp returned by WebPay Create |
nonceStr | Yes | string | random string, get it from metadata.wechatpay.nonceStr returned by WebPay Create |
package | Yes | string | extension order details, get it from metadata.wechatpay.pkg returned by WebPay Create |
signType | Yes | string | Signature Method, get it from metadata.wechatpay.signType returned by WebPay Create |
paySign | Yes | string | Signature, get it from metadata.wechatpay.paySign returned by WebPay Create |
success | No | function | Callback function for successful interface call |
fail | No | function | Callback function for interface call failure |
complete | No | function | The callback function for the end of the interface call (will be executed if the call succeeds or fails) |
# CallBack Result
Callback Type | errMsg | description |
---|---|---|
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 |
# Request example
wx.requestPayment(
{
"timeStamp": "1414561699",
"nonceStr": "5K8264ILTKch16CQ2502SI8ZNMTM67VS",
"package": "prepay_id=wx201410272009395522657a690389285100",
"signType": "RSA",
"paySign": "UGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==",
'success':function(res){},
'fail':function(res){},
'complete':function(res){}
})