Skip to content

Commit

Permalink
feat: IAP 修缮
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin authored and Gavin committed Nov 20, 2024
1 parent dc57748 commit 32accd6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
3 changes: 1 addition & 2 deletions hk/docs/sdk/TapPayments/develop/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import CodeBlock from '@theme/CodeBlock';

### **SDK 初始化**

TapTap 登录模块依赖于 TapTapSDK 初始化,具体参考 [TapSDK 集成](/sdk/access/quickstart/#初始化)
TapTapIAP 模块依赖于 TapTapSDK 初始化,具体参考 [TapSDK 集成](/sdk/access/quickstart/#初始化)

```java

Expand Down Expand Up @@ -164,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
4 changes: 2 additions & 2 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 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ Developers can download the UPM package from [Google APIs for Unity](https://dev

The TapTap IAP can be installed via NPMJS. Developers can register to use NPMJS through **Edit > Project Settings > Package Manager**.

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

<>
After configuration, you can install <strong>TapTapSDK IAP {v4SDKVersions.tapGlobalPayments.unity}</strong> in <strong>Window &gt; Package Manager &gt; My Registries</strong>.
If <code>TapTap Payments Global V2</code> is not in the installation directory, try re-registering NPMJS in <strong>Edit &gt; Project Settings &gt; Package Manager</strong>.
</>

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

### 2. Modify the Packages/manifest.json File

Expand All @@ -71,14 +71,12 @@ The TapTap IAP can be installed via NPMJS. Developers can register to use NPMJS
{
"name": "taptap",
"url": "https://registry.npmjs.org",
"scopes": ["com.tapsdk", "com.taptap", "com.leancloud"]
"scopes": ["com.tapsdk"]
},
{
"name": "openupm",
"url": "https://package.openupm.com",
"scopes": [
"com.google"
]
"scopes": ["com.google"]
}
]`}
</CodeBlock>
Expand Down

0 comments on commit 32accd6

Please sign in to comment.