# 將ONE store In-App支付升级至V21

## 從v19升级至v21 <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-cong-v19-sheng-ji-zhi-v21" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-cong-v19-sheng-ji-zhi-v21"></a>

### 變更支付library <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-zhi-fu-library" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-zhi-fu-library"></a>

ONE store In-App Purchase(IAP) SDK從v21版本開始提供通過maven的發布。

如想要通過maven使用IAP library，請根據以下内容進行更改。

* 刪除v19 AAR文件
  * 刪除Project的libs文件夾中的iap\_sdk-v19.XX.XX.aar文件。
* 添加maven從屬性&#x20;

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>ONE Store IAP SDK 儲存庫將於 <strong>2026 年 4 月 1 日</strong> 起遷移至 <strong>Maven Central</strong>。</p><p>詳細內容請參考 <a href="https://dev.onestore.net/devpoc/support/news/noticeView.omp?noticeId=33714">Notice on Migration of ONE store IAP SDK Repository</a></p></div>

  * 在專案的最上層 `build.gradle` 檔案中新增 ONE store 付款（計費）程式庫的相依項目。

    ```gradle

    dependencies {
        implementation "com.onestorecorp.sdk:sdk-iap:21.04.00"
    }

    ```

  * 以下是在應用軟件的`build.gradle`文件中添加ONE store支付library從屬項目。

    ```gradle

    dependencies {
    def onestore_iap_version = "21.04.00"
    implementation "com.onestorecorp.sdk:sdk-iap:$onestore_iap_version"
    }

    ```

### 變更Json file <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-jsonfile" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-jsonfile"></a>

ONE store從IAP SDK v19開始， 通過global-appstores.json提供SDK使用時必備 param。

從v21開始為了更方便地應用相應值，通過maven發布相應值。

為了變更相關内容，請按照以下内容進行。

* 刪除global-appstores.json<br>
  * 刪除Project的assets文件夾中的global-appstores.json文件
* 添加maven從屬性
  * 在project最上面*build.gradle*文件中註冊ONE store的maven地址。&#x20;

    ```gradle

    allprojects {
    repositories {
    ...
        maven { url 'https://repo.onestore.net/repository/onestore-sdk-public' }
    }
    }

    ```
  * 以下是在應用軟件的*build.gradle*文件中添加ONE store支付library從屬項目。

    ```gradle

    dependencies {
    def onestore_configuration_version = "1.0.0"
    implementation "com.onestorecorp.sdk:sdk-configuration-kr:$onestore_configuration_version"
    }

    ```

### 修改Deprecated項目 <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-xiu-gai-deprecated-xiang-mu" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-xiu-gai-deprecated-xiang-mu"></a>

v21 SDK中的以下項目已被Deprecated。

使用上沒有問題，但是為了以後的順利使用需要變更。

* Interface&#x20;

  | **name**          | **description**                                          |
  | ----------------- | -------------------------------------------------------- |
  | PurchasesListener | 從v21開始，不使用PurchasesListener ，請使用 QueryPurchasesListener。 |
* Method

  | **class**                  | **method name**             | **description**                                                                                                                          |
  | -------------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
  | <p>PurchaseClient<br> </p> | manageRecurringProductAsync | <p>從v21開始支持Subscription(訂閱)商品，而不支持Auto(包月型)商品，通過定期支付選單支持相應功能。<br>定期支付選單不支持包月型商品，因此必須使用相應API提供使用解除的預約/取消。<br>訂閱商品則需要體現為通過定期支付選單向用戶說明。</p> |
  | <p><br></p>                | launchLoginFlowAsync        | <p>認證相關的flow被分離為單獨的 class。<br>詳情請參考InApp Auth運行指南</p>                                                                                    |

## 從v17升级至v21 <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-cong-v17-sheng-ji-zhi-v21" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-cong-v17-sheng-ji-zhi-v21"></a>

### 變更支付library <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-zhi-fu-library.1" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-bian-geng-zhi-fu-library.1"></a>

從v17變更為v21時，library從jar變更為aar。

使用v17 library的開發公司，通過指南將v19升级至v21變更為maven後后，需要對從jar形態轉換為aar發布的部分進行追加操作(刪除meta-data)。

* 刪除v17 jar library <br>
  * 刪除Project的libs文件夾中的jar文件
* 刪除AndroidManifest的以下meta-data&#x20;

  ```xml

  <meta-data android:name="iap:api_version" android:value="5"/>

  ```
* 添加maven從屬性 : 參考從v19升级至v21&#x20;

### 添加Json file從屬性 <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-tian-jia-jsonfile-cong-shu-xing" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-tian-jia-jsonfile-cong-shu-xing"></a>

v19以上開始，SDK的操作需要json文件。請參考[從v19升级至v21 > 變更json file > 添加maven從屬性](#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-tian-jia-jsonfile-cong-shu-xing)在Project裡添加從屬性。

### 修改變更事項 <a href="#id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-xiu-gai-bian-geng-shi-xiang" id="id-jiang-onestoreinapp-zhi-fu-sheng-ji-zhi-v21-xiu-gai-bian-geng-shi-xiang"></a>

請參考[ONE store In-App支付SDK升级指南](/dev/cht/tools/billing/v21/sdk.md)修改變更事項。&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://onestore-dev.gitbook.io/dev/cht/tools/billing/v21/upgrade.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
