【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
该 API 使用方法为 wx.requestPayment(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
timeStamp | string | - | 是 | 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 |
nonceStr | string | - | 是 | 随机字符串,长度为32个字符以下 |
package | string | - | 是 | 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** |
signType | string | - | 是 | 签名算法,应与后台下单时的值一致 通常是: RSA |
paySign | string | - | 是 | |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.requestPayment({timeStamp: '',nonceStr: '',package: '',signType: 'RSA',paySign: '',success (res) {/* res通常由superapp返回给小程序前端,结构由superapp自定义* 按照标准实现,支付成功后 会在这里收到 res.errMsg = ‘requestPayment:ok’* 建议小程序在成功回调里,再调用小程序后台接口进行支付状态的确认。确保支付回调信息已经同步到小程序后台*/if(res.errMsg === 'resquestPayment:ok'){// send request to mini program backend to confirm payment state}},fail (err) {// 该错误内容通常由superapp返回给小程序前端,需要由小程序前端进行报错后的相关用户引导提示}})
该 API 使用方法为 wx.requestVirtualPayment(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
signData | string | - | 是 | 具体支付参数见 signData, 该参数需以 string 形式传递, 例如 signData: '{"offerId":"123","buyQuantity":1,"currencyType":"USD","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}' |
mode | string | - | 是 | 当前仅支持填写 short_series_goods |
signature | string | - | 是 | |
paySign | string | - | 是 | |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
offerId | string | - | 是 | 商户号 ID |
buyQuantity | string | - | 是 | 购买数量 |
currencyType | string | - | 是 | 币种,如:USD,具体见控制台中 App 支持的支付币种 |
productId | string | - | | 道具 ID,该字段 mode=short_series_goods 时需要必填 |
goodsPrice | number | - | | 道具单价(分),该字段 mode=short_series_goods 时需要必填 |
outTradeNo | string | - | 是 | 业务订单号, 每个订单号只能使用一次, 重复使用会失败 |
attach | string | - | 是 | 透传数据, 发货通知时会透传给开发者 |
wx.requestVirtualPayment({signData: JSON.stringify({offerId: '123',buyQuantity: 1,currencyType: 'USD',productId: 'testproductId',goodsPrice: 10,outTradeNo: 'xxxxxx',attach: 'testdata',}),paySig: 'd0b8bbccbe109b11549bcfd6602b08711f46600965253a949cd6a2b895152f9d',signature: 'd0b8bbccbe109b11549bcfd6602b08711f46600965253a949cd6a2b895152f9d',mode: 'short_series_goods',success(res) {console.log('requestVirtualPayment success', res)},fail({ errMsg, errCode }) {console.error(errMsg, errCode)},})
文档反馈