Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: IAP 文档修缮 #1287

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cn/docs/sdk/_partials/unity-sdk-installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ SDK 支持通过 NPMJS 及 GitHub 两种方式,开发者选择其中一种即

<CodeBlock language="json">
{`"dependencies":{
${props.systemNpmDeps}
${props.npmDeps.map(dep => `"${dep}":"${v4SDKVersions.taptap.unity}",`).join('\n ')}
}`}
</CodeBlock>
Expand Down
54 changes: 28 additions & 26 deletions cn/docs/sdk/tap-iap/develop/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import CodeBlock from '@theme/CodeBlock';

## **准备**

- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数并且绑定 API 域名
- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数
- 参照 [TapSDK 快速开始](/sdk/access/quickstart/) 配置包名和签名

## **SDK 指南**
Expand All @@ -41,27 +41,30 @@ import CodeBlock from '@theme/CodeBlock';

### **SDK 初始化**

添加 TapTapIAP 的依赖项后,您需要初始化 `TapTapIAP` 实例。`TapTapIAP` 是 SDK 与应用的其余部分之间进行通信。`TapTapIAP` 为许多常见的操作提供了方法。

首先 在应用启动时需要进行 SDK 初始化, 通过设置 `TapTapSdkOptions`, 完成 SDK 初始化, `TapTapSdk.init` 。

这里需要设置对应在开发者后台申请的 `ClientID` 和 `ClientToken`,用于校验是否有权限使用 `TapTapIAP`。
TapTap 登录模块依赖于 TapTapSDK 初始化,具体参考 [TapSDK 集成](/sdk/access/quickstart/#初始化)

```java
TapTapSdkOptions sdkOptions = new TapTapSdkOptions(
"应用的 ClientID", // clientId 开发者平台申请
"应用的 ClientToken", // clientToken 开发者平台申请
TapTapRegion.GLOBAL, // 地区
"", // 分包渠道名称
"", // 游戏版本, 为空为null会取AppVersion
false, // 是否自动上报GooglePlay内购支付成功事件 仅 [TapTapRegion.GLOBAL] 生效
false, // 自定义字段是否能覆盖内置字段
null, // 自定义属性,启动首个预置事件(device_login)会带上这些属性
null, // OAID证书, 用于上报 OAID 仅 [TapTapRegion.CN] 生效
false // 是否开启 log,建议 Debug 开启,Release 关闭
);

TapTapSdk.init(context, sdkOptions);
import com.taptap.sdk.core.TapTapRegion;
import com.taptap.sdk.core.TapTapSdk;
import com.taptap.sdk.core.TapTapSdkOptions;

/* 必选配置 */
// 开发者中心对应 Client ID
String clientId = "";
// 开发者中心对应 Client Token
String clientToken = "";
// 是否开启 log,建议 Debug 开启,Release 关闭,默认关闭 log
boolean enableLog = BuildConfig.DEBUG;

TapTapSdkOptions tapSdkOptions = new TapTapSdkOptions(
clientId, // 游戏 Client ID
clientToken, // 游戏 Client Token
TapTapRegion.CN // 游戏可玩区域: [TapTapRegion.CN]=国内 [TapTapRegion.GLOBAL]=海外
);
tapSdkOptions.setEnableLog(enableLog);
// 初始化 TapSDK
TapTapSdk.init(context, tapSdkOptions);
```

创建 `TapTapIAP`,请使用 `newBuilder()`这里会根据SDK.init所设置的 `ClientID` 和 `ClientToken`校验是否有权限使用 `TapTapIAP`。
Expand Down Expand Up @@ -98,8 +101,8 @@ tapTapIAP.queryProductDetailsAsync(params, new ProductDetailsResponseListener()
List<ProductDetails> productDetails, List<String> unavailableProductIds) {
...

// check TapPaymentResult
// process returned productDetails
// 判断 TapPaymentResult
// 使用商品详情
}
});
```
Expand All @@ -113,21 +116,21 @@ tapTapIAP.queryProductDetailsAsync(params, new ProductDetailsResponseListener()
Activity activity = ...;
ProductDetailsParams productDetailsParams =
ProductDetailsParams.newBuilder()
// retrieve a value for "productDetails" by calling queryProductDetailsAsync()
// 使用从 queryProductDetailsAsync() 查询回来的商品详情
.setProductDetails(productDetails)
.build();

BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setProductDetailsParams(productDetailsParams)
.setObfuscatedAccountId("xxx") //Specifies an optional obfuscated string that is uniquely associated with the order(or another information) in your app.
.setObfuscatedAccountId("xxx") // 重要, 在这里设置你APP内唯一标识,例如:订单ID等
.build();
// Launch the billing flow
// 发起 IAP 购买流程
TapPaymentResult result = tapTapIAP.launchBillingFlow(activity,
billingFlowParams,
new PurchaseUpdatedListener() {
@Override
public void onPurchaseUpdated(TapPaymentResult result, Purchase purchases) {
// To be implemented in a later section.
// 监听订单回调做相应处理
}
}
);
Expand Down Expand Up @@ -160,7 +163,6 @@ public void onPurchaseUpdated(TapPaymentResult result, Purchase purchase) {
Purchase purchase = ...;
FinishPurchaseParams params = FinishPurchaseParams.newBuilder()
.setId(purchase.getOrderId()) // Required
.setOrderToken(purchase.getOrderToken()) // Required
.setPurchaseToken(purchase.getPurchaseToken()) // Required
.build();
tapTapIAP.finishPurchaseAsync(params, new FinishPurchaseResponseListener() {
Expand Down
80 changes: 17 additions & 63 deletions cn/docs/sdk/tap-iap/develop/unity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sidebar_position: 1

import MultiLang from "/src/docComponents/MultiLang";
import v4SDKVersions from '/src/docComponents/v4SDKVersions';
import UnitySDKInstallation from "../../_partials/unity-sdk-installation.mdx";
import CodeBlock from '@theme/CodeBlock';


Expand All @@ -15,7 +16,7 @@ import CodeBlock from '@theme/CodeBlock';

## 准备

- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数并且绑定 API 域名
- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数
- 参照 [TapSDK 快速开始](/sdk/access/quickstart/) 配置包名和签名

## 获取 SDK
Expand All @@ -24,68 +25,21 @@ import CodeBlock from '@theme/CodeBlock';
Unity 2020.3.15 之前的版本为了避免后面构建报错建议升级 Gradle 版本,可参考该 [Gradle 升级步骤文档](/sdk/tap-iap/faq/#1unity-2020315-之前的版本升级-gradle-版本的操作步骤)。
:::

以下介绍了**通过 Unity Package Manager 导入**或者**修改 Packages/manifest.json 配置文件引入**两种方式,根据项目需要,任选其一即可:
<UnitySDKInstallation
systemNpmDeps={"\"com\.unity\.purchasing\":\"3\.1\.0\", //TapTap IAP 所须依赖"}
npmDeps={[
"com.taptap.sdk.core",
"com.taptap.sdk.iap",
]}
githubDeps={[
{package: "com.taptap.sdk.core", url: `https://github.com/taptap/TapSDKCore-Unity.git#${v4SDKVersions.taptap.unity}`},
{package: "com.taptap.sdk.iap", url: `https://github.com/taptap/TapSDKLIAP-Unity.git#${v4SDKVersions.taptap.unity}`}
]}
unitypackageModules={[
{name: "TapTapSDK_Core.unitypackage", desc: "TapTapSDK 核心模块,必选"},
{name: "TapTapSDK_IAP.unitypackage", desc: "TapTapSDK 模块IAP,必选"},
]}/>

### 1、通过 Package Manager 可视化界面引入

因为 TapTap IAP 依赖 **EDM4U(External Dependency Manager for Unity)** 来处理 Android 相关的依赖,因此引入依赖的步骤是**先安装 EDM4U 库,然后安装 TapTap IAP**。

#### 安装 EDM4U

下面介绍了两种方式安装 EDM4U,分别是通过 **OpenUPM 安装**以及**手动下载安装**;

- **方法一:通过 OpenUPM 安装 EDM4U**

EDM4U 可以通过 OpenUPM 进行下载,开发者可以通过 **Edit > Project Settings > Package Manager** 来注册使用 OpenUPM。

![](https://capacity-files.lcfile.com/gpS8BcTVJIdSpMxyDipIWORX4Gb2filA/NdoQbmRRvovet4x3LGUcsTXWnjb.png)

- **方法二:手动下载安装**

开发者可以通过 [Google APIs for Unity](https://developers.google.com/unity/archive#external_dependency_manager_for_unity) 下载 UPM 安装包. 并且通过[从本地磁盘安装](https://docs.unity3d.com/Manual/upm-ui-local.html)的方式进行安装。

#### 安装 TapTap IAP

TapTap IAP 可以通过 NPMJS 进行安装, 开发者可以通过 **Edit > Project Settings > Package Manager** 来注册使用 NPMJS。

![](https://capacity-files.lcfile.com/sJDhXK4vAwAYX7BpQFh1SrQzeUmXk165/taptap.png)

<>
配置完成以后就可以在 <strong>Window &gt; Package Manager &gt; My Registries</strong> 中安装 <strong>TapTapSDK IAP {v4SDKVersions.taptap.unity}</strong>。
如果安装目录中没有 <code>TapTapSDK IAP</code>, 请尝试在 <strong>Edit &gt; Project Settings &gt; Package Manager</strong> 中重新注册 NPMJS。
</>

![](https://img.tapimg.com/market/images/cda0911e47723fba9bee9a29ef62260f.png)


### 2、修改 Packages/manifest.json 文件

<CodeBlock className="json">
{` "dependencies": {
"com.taptap.sdk.iap": "${v4SDKVersions.taptap.unity}", //添加 TapTap IAP
"com.unity.purchasing": "3.1.0", //TapTap IAP 所须依赖
"com.google.external-dependency-manager": "1.2.179", //TapTap IAP 所须依赖
"com.taptap.sdk.core": "${v4SDKVersions.taptap.unity}",
...
...
},

// 添加 Registries
"scopedRegistries": [
{
"name": "taptap",
"url": "https://registry.npmjs.org",
"scopes": ["com.tapsdk", "com.taptap", "com.leancloud"]
},
{
"name": "openupm",
"url": "https://package.openupm.com",
"scopes": [
"com.google"
]
}
]`}
</CodeBlock>


:::tip
Expand Down Expand Up @@ -149,7 +103,7 @@ public class MyIAPManager : IStoreListener {
var builder = ConfigurationBuilder.Instance(TapPurchasingModule.Instance);
builder.Configure<ITapTapStoreConfiguration>().SetClientId("Your Client ID Here");
builder.Configure<ITapTapStoreConfiguration>().SetClientToken("Your Client Token Here");
builder.Configure<ITapTapStoreConfiguration>().SetRegionCode(1); // 0: CN, 1: GLOBAL
builder.Configure<ITapTapStoreConfiguration>().SetRegionCode(0); // 0: CN, 1: GLOBAL
builder.AddProduct("100_gold_coins", ProductType.Consumable);

UnityPurchasing.Initialize (this, builder);
Expand Down
3 changes: 2 additions & 1 deletion cn/docs/tap-download.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TapSDK 为我们提供的众多服务的总称,为了方便开发者按需接
| 正版验证 | tap-license | https://mvnrepository.com/artifact/com.taptap.sdk/tap-license |
| 分享 | tap-share | https://mvnrepository.com/artifact/com.taptap.sdk/tap-share |
| 评价 | tap-review | https://mvnrepository.com/artifact/com.taptap.sdk/tap-review |
| 内购服务 | tap-iap | https://mvnrepository.com/artifact/com.taptap.android.payment/iap <br/> https://mvnrepository.com/artifact/com.taptap.android.payment/checkout <br/> https://mvnrepository.com/artifact/com.taptap.android.payment/core <br/> https://mvnrepository.com/artifact/com.taptap.android.payment/base <br/> https://mvnrepository.com/artifact/com.taptap.android.payment/alipaycn <br/> https://mvnrepository.com/artifact/com.taptap.android.payment/wechat |

<h3> iOS { v4SDKVersions.taptap.ios}</h3>

Expand All @@ -55,7 +56,7 @@ TapSDK 为我们提供的众多服务的总称,为了方便开发者按需接
| 成就系统 | tap-achievement | https://github.com/taptap/TapSDKAchievement-Unity/releases |
| 正版验证 | tap-license | https://github.com/taptap/TapSDKLicense-Unity/releases |
| 评价 | tap-review | https://github.com/taptap/TapSDKReview-Unity/releases |

| 内购服务 | tap-iap | https://github.com/taptap/TapSDKIAP-Unity/releases |

## 商业变现
TapADN SDK 是由「易玩(上海)网络科技有限公司」开发,向媒体提供丰富的广告资源,依托高效的算法引擎,帮助开发者实现流量变现。<br></br>
Expand Down
42 changes: 22 additions & 20 deletions hk/docs/sdk/TapPayments/develop/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import CodeBlock from '@theme/CodeBlock';

## **准备**

- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数并且绑定 API 域名
- 参照 [准备工作](/sdk/access/get-ready/) 所述创建 app,配置 app 参数
- 参照 [TapSDK 快速开始](/sdk/access/quickstart/) 配置包名和签名

## **SDK 指南**
Expand All @@ -42,27 +42,30 @@ import CodeBlock from '@theme/CodeBlock';

### **SDK 初始化**

添加 TapTapIAP 的依赖项后,您需要初始化 `TapTapIAP` 实例。`TapTapIAP` 是 SDK 与应用的其余部分之间进行通信。`TapTapIAP` 为许多常见的操作提供了方法。

首先 在应用启动时需要进行 SDK 初始化, 通过设置 `TapTapSdkOptions`, 完成 SDK 初始化, `TapTapSdk.init` 。

这里需要设置对应在开发者后台申请的 `ClientID` 和 `ClientToken`,用于校验是否有权限使用 `TapTapIAP`。
TapTapIAP 模块依赖于 TapTapSDK 初始化,具体参考 [TapSDK 集成](/sdk/access/quickstart/#初始化)

```java
TapTapSdkOptions sdkOptions = new TapTapSdkOptions(
"应用的 ClientID", // clientId 开发者平台申请
"应用的 ClientToken", // clientToken 开发者平台申请
TapTapRegion.GLOBAL, // 地区
"", // 分包渠道名称
"", // 游戏版本, 为空为null会取AppVersion
false, // 是否自动上报GooglePlay内购支付成功事件 仅 [TapTapRegion.GLOBAL] 生效
false, // 自定义字段是否能覆盖内置字段
null, // 自定义属性,启动首个预置事件(device_login)会带上这些属性
null, // OAID证书, 用于上报 OAID 仅 [TapTapRegion.CN] 生效
false // 是否开启 log,建议 Debug 开启,Release 关闭
);

TapTapSdk.init(context, sdkOptions);
import com.taptap.sdk.core.TapTapRegion;
import com.taptap.sdk.core.TapTapSdk;
import com.taptap.sdk.core.TapTapSdkOptions;

/* 必选配置 */
// 开发者中心对应 Client ID
String clientId = "";
// 开发者中心对应 Client Token
String clientToken = "";
// 是否开启 log,建议 Debug 开启,Release 关闭,默认关闭 log
boolean enableLog = BuildConfig.DEBUG;

TapTapSdkOptions tapSdkOptions = new TapTapSdkOptions(
clientId, // 游戏 Client ID
clientToken, // 游戏 Client Token
TapTapRegion.GLOBAL // 游戏可玩区域: [TapTapRegion.CN]=国内 [TapTapRegion.GLOBAL]=海外
);
tapSdkOptions.setEnableLog(enableLog);
// 初始化 TapSDK
TapTapSdk.init(context, tapSdkOptions);
```

创建 `TapTapIAP`,请使用 `newBuilder()`这里会根据SDK.init所设置的 `ClientID` 和 `ClientToken`校验是否有权限使用 `TapTapIAP`。
Expand Down Expand Up @@ -161,7 +164,6 @@ public void onPurchaseUpdated(TapPaymentResult result, Purchase purchase) {
Purchase purchase = ...;
FinishPurchaseParams params = FinishPurchaseParams.newBuilder()
.setId(purchase.getOrderId()) // Required
.setOrderToken(purchase.getOrderToken()) // Required
.setPurchaseToken(purchase.getPurchaseToken()) // Required
.build();
tapTapIAP.finishPurchaseAsync(params, new FinishPurchaseResponseListener() {
Expand Down
10 changes: 4 additions & 6 deletions hk/docs/sdk/TapPayments/develop/unity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ EDM4U 可以通过 OpenUPM 进行下载,开发者可以通过 **Edit > Project

TapTap IAP 可以通过 NPMJS 进行安装, 开发者可以通过 **Edit > Project Settings > Package Manager** 来注册使用 NPMJS。

![](https://capacity-files.lcfile.com/sJDhXK4vAwAYX7BpQFh1SrQzeUmXk165/taptap.png)
![](https://img.tapimg.com/market/images/4f0d11b80a358ff0f714b37a51d6007f.png)

<>
配置完成以后就可以在 <strong>Window &gt; Package Manager &gt; My Registries</strong> 中安装 <strong>TapTapSDK IAP {v4SDKVersions.tapGlobalPayments.unity}</strong>。
如果安装目录中没有 <code>TapTap Payments Global V2</code>, 请尝试在 <strong>Edit &gt; Project Settings &gt; Package Manager</strong> 中重新注册 NPMJS。
</>

![](https://img.tapimg.com/market/images/cda0911e47723fba9bee9a29ef62260f.png)
![](https://img.tapimg.com/market/images/58581dbaaf3b269c453b0781e3a22a55.png)


### 2、修改 Packages/manifest.json 文件
Expand All @@ -75,14 +75,12 @@ TapTap IAP 可以通过 NPMJS 进行安装, 开发者可以通过 **Edit > Proje
{
"name": "taptap",
"url": "https://registry.npmjs.org",
"scopes": ["com.tapsdk", "com.taptap", "com.leancloud"]
"scopes": ["com.taptap"]
},
{
"name": "openupm",
"url": "https://package.openupm.com",
"scopes": [
"com.google"
]
"scopes": ["com.google"]
}
]`}
</CodeBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,29 @@ Open the `project/app/build.gradle` file of your project and add the following g

### **SDK Initialization**

After adding the TapTapIAP dependency, you need to initialize the `TapTapIAP` instance. `TapTapIAP` communicates between the SDK and the rest of your application, providing methods for many common operations.
The TapTapIAP module relies on the initialization of the TapTapSDK. For details, refer to [TapSDK Integration](/sdk/access/quickstart/#Initialization).

First, initialize the SDK during app launch by setting `TapTapSdkOptions` and completing SDK initialization with `TapTapSdk.init`.
```java
import com.taptap.sdk.core.TapTapRegion;
import com.taptap.sdk.core.TapTapSdk;
import com.taptap.sdk.core.TapTapSdkOptions;

You need to set the `ClientID` and `ClientToken` obtained from the developer backend for permission validation to use `TapTapIAP`.
String clientId = "";

```java
TapTapSdkOptions sdkOptions = new TapTapSdkOptions(
"Your App's ClientID", // clientId obtained from the developer platform
"Your App's ClientToken", // clientToken obtained from the developer platform
TapTapRegion.GLOBAL, // Region
"", // Sub-package channel name
"", // Game version, null will take AppVersion
false, // Automatically report GooglePlay purchase success event, effective only for [TapTapRegion.GLOBAL]
false, // Custom fields can overwrite built-in fields
null, // Custom attributes, included with the first preset event (device_login)
null, // OAID certificate, used for reporting OAID, effective only for [TapTapRegion.CN]
false // Enable log, recommended to enable in Debug and disable in Release
String clientToken = "";
// Enable the log. It's recommended to turn it on for Debug and off for Release, with it being off by default.
boolean enableLog = BuildConfig.DEBUG;

TapTapSdkOptions tapSdkOptions = new TapTapSdkOptions(
clientId, // clientId obtained from the developer platform
clientToken, // clientToken obtained from the developer platform
TapTapRegion.GLOBAL // Region: TapTapRegion.CN, TapTapRegion.GLOBAL
);
tapSdkOptions.setEnableLog(enableLog);

TapTapSdk.init(context, tapSdkOptions);


TapTapSdk.init(context, sdkOptions);
```

To create `TapTapIAP`, use `newBuilder()`, which will validate the permissions to use `TapTapIAP` based on the `ClientID` and `ClientToken` set in SDK.init.
Expand Down Expand Up @@ -158,7 +160,6 @@ After a user completes the purchase of any product, confirm that the correspondi
Purchase purchase = ...;
FinishPurchaseParams params = FinishPurchaseParams.newBuilder()
.setId(purchase.getOrderId()) // Required
.setOrderToken(purchase.getOrderToken()) // Required
.setPurchaseToken(purchase.getPurchaseToken()) // Required
.build();
tapTapIAP.finishPurchaseAsync(params, new FinishPurchaseResponseListener() {
Expand Down
Loading
Loading