【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
该 API 使用方法为 wx.requestMidasPaymentGameItem(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
signData | string | - | 是 | 支付原串 具体支付参数见下面的 signData,需要将数据以 json格式传递。signData 例子: '{"mode":"goods","buyQuantity":1,"currencyType":"USD","platform":"android","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}' |
paySig | string | - | 是 | 支付签名 pay_sig 参数的签名算法。使用密钥 appkey(小程序平台不参与加解密及签名验证过程,因此需小游戏与 superApp 自行完成密钥的交换)对支付的请求进行签名,代表请求经过开发者服务端的支付模块发起。签名算法伪代码为: paySig = to_hex(hmac_sha256(appkey,'requestMidasPaymentGameItem' + '&' + signData)) |
signature | string | - | 是 | 用户态签名 signature 参数签名算法。伪代码为:signature = hmac_sha256(session_key, rawData) |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
mode | string | - | 是 | 支付的类型 不同的支付类型有各自额外要传的附加参数 |
buyQuantity | number | - | 是 | 购买数量 |
currencyType | string | - | 是 | 币种,例如 USD(以当前接入的 superapp 支持的币种为准) |
platform | string | - | 否 | 平台,取值为 android 或 ios |
productId | string | - | 是 | 道具 ID |
goodsPrice | number | - | 是 | 道具单价(分) 用来校验价格和后台道具价格是否一致 |
outTradeNo | string | - | 是 | 业务订单号 每个订单号只能使用一次,重复使用会失败。 要求 32 个字符内,只能是数字、大小写字母、符号 _-|*@组成,不能以下划线(_)开头。 |
attach | string | - | 否 | 透传数据 发货通知时会透传给开发者 |
错误码 | 说明 |
-15001 | 虚拟支付接口错误码,缺少参数 |
-15002 | 虚拟支付接口错误码,参数不合法 |
-15003 | 虚拟支付接口错误码,订单重复 |
-15004 | 虚拟支付接口错误码,后台错误 |
-15005 | 虚拟支付接口错误码,appId 权限被封禁 |
-15006 | 虚拟支付接口错误码,货币类型不支持 |
-15012 | signature 错误 |
-15014 | paySig 错误 |
-15015 | sessionKey 过期 |
-15016 | 道具价格错误 |
-16001 | 平台业务错误码,商户信息不存在 |
-16002 | 平台业务错误码,道具不存在 |
-16003 | 平台业务错误码,小游戏推送配置不存在 |
-16004 | 平台业务错误码,道具未注册 |
-16005 | 平台业务错误码,superapp 后台服务未配置 |
-16006 | 平台业务错误码,superapp 支付未开启 |
wx.requestMidasPaymentGameItem({signData: '{"mode":"goods","buyQuantity":1,"currencyType":"{set by yourself}","platform":"android","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}',paySig: 'd0b8bbccbe34ed11549bcfd6602b08711f4acc0965253a949cd6a2b895152f9d',signature: 'd0b8bbccbe34ed11549bcfd6602b08711f4acc0965253a949cd6a2b895152f9d',success({errMsg, errCode }) {console.log('pay', errCode);},fail({ errMsg, errCode }) {console.error(errMsg, errCode)}
文档反馈