# 支付
# 一、介绍
该模块用于游戏内的虚拟货币查询,支付和充值。 使用前,请前往对应平台开通支付功能
# 二、使用
- 查询
// 在头部引入支付系统
import { paymentSystem } from "@timi/mogs-sdk";
...
// 使用
const account = await accountSystem.account;
const res = await paymentSystem.getBalance();
cc.find("Canvas/Balance").getComponent(cc.Label).string =
"游戏币余额:" + res.balance;
cc.find("Canvas/GiftedBalance").getComponent(cc.Label).string =
"赠送游戏币余额:" + res.giftedBalance;
cc.find("Canvas/IsFirstSaveAvailable").getComponent(cc.Label).string =
"是否充值过:" + (res.isFirstRechargeAvailable ? "否" : "是");
cc.find("Canvas/TotalAmount").getComponent(cc.Label).string =
"历史总游戏币金额:" + res.totalAmount;
cc.find("Canvas/TotalChargedAmount").getComponent(cc.Label).string =
"历史累计充值游戏币金额:" + res.totalChargedAmount;
cc.find("Canvas/TotalConsumedAmount").getComponent(cc.Label).string =
"历史总消费游戏币金额:" + res.totalConsumedAmount;
cc.find("Canvas/TotalGiftedAmount").getComponent(cc.Label).string =
"历史累计收到赠送游戏币金额:" + res.totalGiftedAmount;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
- 支付
// 在头部引入支付系统
import { paymentSystem } from "@timi/mogs-sdk";
...
// 使用
paymentSystem.pay({
amount: amount // 消耗的游戏币数量
});
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- 充值
// 在头部引入mogs
import mogs from "@timi/mogs-sdk";
...
// 使用
mogs.requestMidasPayment({
mode: "game",
env: 1,
currencyType: "CNY",
buyQuantity: this.chargeCount,
platform: "android",
zoneId: "1",
offerId: "**************",
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
TIP
requestMidasPayment具体参数说明参考微信虚拟支付功能 (opens new window)
← MOGS 管理系统使用 广告 →