# 兑换道具

服务器接口

POST https://allin.kuaishoupay.com/api/kpay/minigame/pay

Content-type: x-www-form-urlencoded

Body

属性 类型 说明
access_token string 游戏服务器通过 获取 access_token 接口获取(不参与签名)
open_id string 游戏服务器通过 code2Session 接口换的用户唯一标识(参与签名)
app_id string 应用id (参与签名)
zone_id string 角色id,请按照 区服ID + “_” + 角色ID 的格式拼接 (参与签名)
os string 用户平台 (参与签名)
ts long 时间戳 (参与签名)
user_ip string 用户客户端ip (参与签名)
amount long 游戏币数量 (参与签名)
pay_priority int 扣除货币的优先级0:优先扣除充值货币,默认值1:优先扣除赠送货币 (参与签名,可为空,为空时不参与签名)
biz_no string 游戏业务订单号,游戏需要确保全局唯一,相同订单号不会重复扣款,长度不超过63字节,数字字符不限,不能包含特殊字符,有效期48小时 (参与签名)
product_name string 道具名称(如果是礼包,则是礼包名称) (参与签名)
product_info string 道具信息列表List<item>,item取值如下表,需要将JsonArray转成JsonString,见下面示例代码 (参与签名)
product_desc string 备注 (参与签名)
extension string 开发者自定义的其他信息,非必填,当为非空字符串时参与签名,否则不参与签名
sign string 签名,需要 encode (不参与签名),签名规则

product_info中item结构

属性 类型 说明
product_id long 道具id
product_num int 道具数量
product_type int 道具类型,0:一次性道具,如双倍卡;1:有效期道具,如月卡;2:永久性道具,如皮肤
product_start_time long 道具有效期开始时间,单位毫秒,product_type为1时必填
product_period long 道具有效期结束时间,单位毫秒,product_type为1时必填

product_info字段代码示例,javascript代码,其他语言类比实现即可

let items = [
    {
        product_id: 1,
        product_num: 1,
        product_type: 1,
        product_start_time: Date.now(),
        product_period: 1
    }
]
var product_info = JSON.stringify(items)

返回结果示例

{
   "code": 1,
   "msg": "SUCCESS",
   "data": {
       "bizNo": "768680008989",
       "freeBalance": 70,
       "chargeBalance": 70
   }
}