title: Taro.requestPayment(option)
sidebar_label: requestPayment
Initiates a request for payment via WeChat Pay. For more information, see WeChat Pay API Documentation.
Reference
Type
(option: Option) => Promise<CallbackResult>
Parameters
Option
Property |
Type |
Required |
Description |
nonceStr |
string |
Yes |
A random string of less than 32 characters |
package |
string |
Yes |
The value of the prepay_id parameter returned by the unified order placement API, which should be submitted in the format of prepay_id=*. |
paySign |
string |
Yes |
Signature. For specific signature schemes, see Mini Program Pay API Documentation |
timeStamp |
string |
Yes |
Timestamp in seconds, from January 1st 1970 at 00:00:00 to the present time |
signType |
"MD5" | "HMAC-SHA256" |
No |
签名算法 |
complete |
(res: any) => void |
No |
The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail |
(res: any) => void |
No |
The callback function for a failed API call |
success |
(res: Result) => void |
No |
The callback function for a successful API call |
signType
Property |
Description |
MD5 |
Only available in WeChat Pay v2 interface |
HMAC-SHA256 |
Only available in WeChat Pay v2 interface |
RSA |
Only available in WeChat Pay v3 interface |
Sample Code
Taro.requestPayment({
timeStamp: '',
nonceStr: '',
package: '',
signType: 'MD5',
paySign: '',
success: function (res) { },
fail: function (res) { }
})
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
Taro.requestPayment |
✔️ |
✔️ |
|