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

  1. (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

  1. Taro.requestPayment({
  2. timeStamp: '',
  3. nonceStr: '',
  4. package: '',
  5. signType: 'MD5',
  6. paySign: '',
  7. success: function (res) { },
  8. fail: function (res) { }
  9. })

API Support

API WeChat Mini-Program H5 React Native
Taro.requestPayment ✔️ ✔️