title: Taro.requestOrderPayment(option)

sidebar_label: requestOrderPayment

创建自定义版交易组件订单,并发起支付。 仅接入了自定义版交易组件的小程序需要使用,普通小程序可直接使用 Taro.requestPayment

支持情况:requestOrderPayment - 图1 requestOrderPayment - 图2 requestOrderPayment - 图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=*
orderInfo any 订单信息,仅在需要校验的场景下需要传递,具体见接口说明
extUserUin string 外部 APP 用户 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 版本接口适用

示例代码

除 orderInfo 以外,其余字段与 Taro.requestPayment 一致

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