title: Taro.requestPayment(option)

sidebar_label: requestPayment

发起微信支付。了解更多信息,请查看微信支付接口文档

支持情况:requestPayment - 图1 requestPayment - 图2 requestPayment - 图3

参考文档

类型

  1. (option: Option) => Promise<TaroGeneral.CallbackResult>

参数

参数 类型
option Option

Option

参数 类型 必填 说明
timeStamp string 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间
nonceStr string 随机字符串,长度为32个字符以下
package string 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*
signType keyof SignType 签名算法
paySign string 签名,具体签名方案参见 小程序支付接口文档
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

SignType

参数 说明
MD5 仅在微信支付 v2 版本接口适用
HMAC-SHA256 仅在微信支付 v2 版本接口适用
RSA 仅在微信支付 v3 版本接口适用

示例代码

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