# GHOME OneStoreSDK 开发手册 for Android 国际版
更新日期:2024.05.15
# 1. 前言
本文用于指导游戏开发商接入SDK,本文档仅说明与 Android Google 文档不一致内容,具体接入详情请查阅 Android Google 文档;
# 2. SDK接入流程概述
- 参考 Android Google 文档接入流程。
# 2.1. 接入前必备
- 参考 Android Google 文档接入前必备。
# 3. 开发环境要求
# 3.1. 集成SDK文件到游戏工程
- !!!提示!!!下载 sdk 后参考接入指南
- 根据接入指南将所选的 .ar 文件放在游戏项目的libs文件夹下
- 项目build.gradle文件参考build.gradle文件
- 项目根目录的build.gradle文件参考app_build.gradle文件
- 项目根目录下的gradle.properties参考gradle.properties文件
# 3.2 增加 google,facebook,line,twitter登录配置
- 参考 Android Google 文档 3.2 模块。
# 3.3. 增加Onestore支付配置
在manifest中增加如下配置
<meta-data android:name="onestorePayId" android:value="请填写onestore密钥串" />
1
2
# 3.4. One store的支付界面定义
full: 全屏(竖屏,固定) popup: 弹窗界面(竖屏&横屏) 如果未添加任何值,将默认为是全屏(android:value="full")。
<meta-data
android:name="iap:view_option"
android:value="full或者popup" />
<manifest>
1
2
3
4
2
3
4
# 4. 支付功能(必接)
- 参考 Android Google 文档支付功能。
# 4.1 客户端获取onestore商店商品信息
游戏客户端可以调用获取商店商品信息接口得到对应商品id在onestore后台中中具体商品信息。
接口:
getProductMsgInfo(final Activity activity,final List productIdList, final Callback callback);
参数说明:
activity: Activity对象。
productIdList: 必传,在手游直通车平台上设置的商品的ID集合。
callback: 回调对象,用来回调执行结果,详情请参考代码事例。
代码示例:
List productIdList = new ArrayList(); productIdList.add("test0000001"); productIdList.add("test0000002"); productIdList.add("test0000003"); GHome.getInstance().getProductMsgInfo(DemoActivity.this, productIdList, new Callback() { @Override public void callback(int code, String errMsg, Map<String, String> data) { if (code == ErrorCode.ERROR_NO_ERROR) { // 获取onestore商品信息成功 // 该json为onestore商品信息透传,祥见5. 附录A:查询onestore商品信息透传 String json = data.get("data"); // Gson gson = new Gson(); // List<com.gaa.sdk.iap.ProductDetail> productDetailList = gson.fromJson(data.get("data"), new TypeToken<List<com.gaa.sdk.iap.ProductDetail>>() {}.getType()); } else { // 获取onestore商品信息失败 } } });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 5. 附录A:查询onestore商品信息透传
[
{
"a": "{"freeTrialPeriod":0,"paymentGracePeriod":0,"price":"500","priceAmountMicros":500000000,"priceCurrencyCode":"KRW","productId":"test0000001","promotionPriceMicros":0,"promotionUsePeriod":0,"subscriptionPeriod":0,"title":"测试商品1","type":"inapp"}",
"b": {
"nameValuePairs": {
"freeTrialPeriod": 0,
"paymentGracePeriod": 0,
"price": "500",
"priceAmountMicros": 500000000,
"priceCurrencyCode": "KRW",
"productId": "test0000001",
"promotionPriceMicros": 0,
"promotionUsePeriod": 0,
"subscriptionPeriod": 0,
"title": "测试商品1",
"type": "inapp"
}
}
},
{
"a": "{"freeTrialPeriod":0,"paymentGracePeriod":0,"price":"1000","priceAmountMicros":1000000000,"priceCurrencyCode":"KRW","productId":"test0000002","promotionPriceMicros":0,"promotionUsePeriod":0,"subscriptionPeriod":0,"title":"测试商品2","type":"inapp"}",
"b": {
"nameValuePairs": {
"freeTrialPeriod": 0,
"paymentGracePeriod": 0,
"price": "1000",
"priceAmountMicros": 1000000000,
"priceCurrencyCode": "KRW",
"productId": "test0000002",
"promotionPriceMicros": 0,
"promotionUsePeriod": 0,
"subscriptionPeriod": 0,
"title": "测试商品2",
"type": "inapp"
}
}
},
{
"a": "{"freeTrialPeriod":0,"paymentGracePeriod":0,"price":"1200","priceAmountMicros":1200000000,"priceCurrencyCode":"KRW","productId":"test0000003","promotionPriceMicros":0,"promotionUsePeriod":0,"subscriptionPeriod":0,"title":"测试商品3","type":"inapp"}",
"b": {
"nameValuePairs": {
"freeTrialPeriod": 0,
"paymentGracePeriod": 0,
"price": "1200",
"priceAmountMicros": 1200000000,
"priceCurrencyCode": "KRW",
"productId": "test0000003",
"promotionPriceMicros": 0,
"promotionUsePeriod": 0,
"subscriptionPeriod": 0,
"title": "测试商品3",
"type": "inapp"
}
}
}
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56