# 支付

# ks.requestGamePayment(Object obejct)

前端接口

支付接口,回调结果并不代表购买流程完成,需要游戏服务器确定支付结果。

# 注意事项

使用 ks.requestGamePayment 下单时,服务器回调 字段包含 open_id(参与签名),不包含 game_user_id 。开发者从 ks.requestPayment 更新到 ks.requestGamePayment 时,务必同步更新服务器回调

# 参数

Object obejct

属性 类型 说明 最低版本
success function 调用成功的回调函数
fail function 调用失败的回调函数
complete function 调用完成的回调函数
zone_id string 请按照 区服ID + “_” + 角色ID 的格式拼接 serverId_roleId (参与签名)
os string 系统(参与签名)
currency_type string 货币类型(参与签名)
buy_quantity int 购买数量(参与签名)
third_party_trade_no string 游戏定义的订单id (参与签名)
extension string 拓展字段,非必填,当为空时不参与签名,有值时需要参与签名
product_type int iOS支付需要。表示支付的类型,1表示消耗型,2表示非消耗型(不参与签名)
sign string 订单签名信息(不参与签名),签名规则

os的合法值

说明 最低版本
'android' Android系统
'ios' iOS系统 12.3.10

currency_type的合法值

说明 最低版本
'CNY' 人民币

success的参数

属性 类型 说明 最低版本
code int 状态码
msg string 信息
orderID string 订单ID

fail的参数

属性 类型 说明 最低版本
code int 错误码
msg string 错误描述

# buyQuantity 限制说明

购买游戏币的时候,buyQuantity 不可任意填写,取值只可以为下表中的值。需满足 buyQuantity * 游戏币单价 = 限定的价格等级。游戏币单价固定为 0.1 元,一次购买最少数量是 10。

buyQuantity 与 用户支付金额关系如下:

buyQuantity 用户支付金额(单位:元 )
10 1
30 3
60 6
80 8
120 12
180 18
250 25
300 30
400 40
450 45
500 50
600 60
680 68
730 73
780 78
880 88
980 98
1080 108
1180 118
1280 128
1480 148
1680 168
1880 188
1980 198
3280 328
6480 648
9980 998
19980 1998
29980 2998

# 示例代码

let model = getOrderFromServer();//从服务器获取订单,包含签名
let params = {};
params.success = (result) => {
  this.content.string = "支付结果: " + JSON.stringify(result);
}
params.fail = (result) => {
  this.content.string = "支付失败: " + JSON.stringify(result);
}
params.zone_id              = model.zone_id
params.os                   = model.os
params.currency_type        = model.currency_type
params.buy_quantity         = model.buy_quantity
params.third_party_trade_no = model.third_party_trade_no
params.extension            = model.extension
params.sign                 = model.sign
ks.requestGamePayment(params);