支付
游戏方接入迅雷游戏平台,游戏内各项支付需要通过迅雷支付通道来进行。
目前迅雷支付通道支持的支付方式有:微信(必须安装有微信 APP)和支付宝支付(支持 H5 网页和支付宝 APP 两种)

一、后端对接
请完成后端内购支付的接入,在后端实现对应接口后,再执行下一步操作。
未实现后端接口就进行页面对接,可能会触发平台服务器的告警。
二、客户端对接
调用方法
import android.app.Activity;
import com.xunlei.niux.mobilegame.sdk.pay.GamePayInfo;
import com.xunlei.niux.mobilegame.sdk.platform.NiuxMobileGame;
NiuxMobileGame.getInstance().chargePay(Activity mActivity, String productId, int ammount, float money, String ext, GamePayInfo.PaySignExt paySignExt);
参数说明
参数 | 类型 | 长度限制 | 示例 | 说明 |
---|---|---|---|---|
productId | string | 255 | 2321334 | 迅雷提供的 product_id |
amount | int | 1 | 价格,单位“分”。仅展示用,实际支付价格走后端价格检验接口 | |
money | float | 10.0 | 用于显示的价格,单位“元”,含义同上 | |
ext | string | 1024 | json 字符串,具体内容见下方说明 | |
paySignExt | string | 生成的签名 |
ext 参数说明
参数 | 类型 | 长度限制 | 示例 | 说明 |
---|---|---|---|---|
cpOrderId | string | 255 | 游戏方的订单号 | |
coopid | string | 255 | 平台的游戏方 ID(由平台提供) | |
gameId | string | 255 | 119121100 | 平台的游戏 ID(由平台提供) |
gameName | string | 255 | 平台的游戏名称(由平台提供) | |
serverId | string | 255 | 游戏的区服 ID,没有则不填 | |
productName | string | 255 | 游戏的商品名称 | |
其他字段 | string / number | 其它自定义字段,回调游戏方接口时数据会写到 ext2 参数里面,参数不宜过多过长。 |
调用示例
String productId = "123123";
float money = 100.55;
int amount = 1;
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("my", "test");
jsonObject.put("key", "signkey");
jsonObject.put("productName", "充值产品");
} catch (JSONException e) {
e.printStackTrace();
}
// paySignExt 如果有跟迅雷平台协议好的加密算法则游戏方补充上,没有则忽略
GamePayInfo.PaySignExt paySignExt = new GamePayInfo.PaySignExt();
NiuxMobileGame.getInstance().chargePay(mActivity, productId, amount, money, jsonObject.toString(), paySignExt);
返回支付结果
支付后,支付结果会通过 NiuxMobileGameListener.onChargeFinish
接口回调返回:
import cloud.xbase.sdk.oauth.NiuxMobileGameListener;
/**
* result 支付结果,参考下说明
* count 数量
* productId 同上的 productid/activityId
* orderid 迅雷订单ID
*/
NiuxMobileGameListener.onChargeFinish(int result, int count, String productId, String orderid) {}
响应 result
说明
返回值 | 说明 |
---|---|
0 | 成功 |
-1 | 取消 |
1 | 失败 |