> For the complete documentation index, see [llms.txt](https://onestore-dev.gitbook.io/dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://onestore-dev.gitbook.io/dev/tools/billing/old-version/v19/undefined-3/classes/purchaseclient.md).

# PurchaseClient

```
public abstract class BillingClient extends Object
```

```
java.lang.Object
    ↳ com.gaa.sdk.iap.PurchaseClient
```

<br>

라이브러리와 사용자 어플리케이션 코드 간의 통신을 위한 기본 인터페이스 입니다.

모든 메서드는 비동기로 처리되며 UI thread에서 호출되어야 하며 모든 콜백은 UI thread로 반환됩니다.

이 클래스를 인스턴스화한 후 연결 설정을 하려면 `startConnection(`[`PurchaseClientStateListener`](/dev/tools/billing/old-version/v19/undefined-3/interfaces/purchaseclientstatelistener.md)`)` 메서드를 호출하고 설정이 완료되면 리스너를 통해 알림을 받을 수 있습니다.

| `class` `YourPurchaseManager implements` `PurchaseClientStateListener {     private` `PurchaseClient mPurchaseClient;` `public` `YourPurchaseManager() {         mPurchaseClient = PurchaseClient.newBuilder(activity)                     .setBase64PublicKey(/* your public key */)                     .setListener(this)                     .build();     } ... }` |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

\
일반적으로 설정이 완료되면 구매내역 조회와 인앱 상품의 상세정보를 호출합니다. `queryPurchasesAsync(String,` [`PurchasesListener`](/dev/tools/billing/old-version/v19/undefined-3/interfaces/purchaseslistener.md)`)` 및 `queryProductDetailsAsync(`[`ProductDetailsParams`](/dev/tools/billing/old-version/v19/undefined-3/classes/productdetailsparams.md)`,` [`ProductDetailsListener`](/dev/tools/billing/old-version/v19/undefined-3/interfaces/productdetailslistener.md)`)` 참조하세요.

이 객체로 모든 작업을 마치고 어플리케이션을 종료할 때는 `endConnection()`의 호출을 잊지마십시오. 결제 모듈과의 연결해제 및 자원을 해제해야 합니다. 권장 위치는 `Activity.onDestroy()` 입니다.

라이브러리의 자세한 로그를 확인하려면 `Logger.setLogLevel(int)` 에 `android.util.Log.VERBOSE` 입력하여 호출하면 됩니다.\
주의!!! 어플리케이션의 릴리즈 버전을 출시 전에 꼭! `Logger.setLogLevel(int)`를 제거 하십시오.

## Summary <a href="#purchaseclient-summary" id="purchaseclient-summary"></a>

***

| Nested classes |                                                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| @interface     | [PurchaseClient.ResponseCode](/dev/tools/billing/old-version/v19/undefined-3/annotations/purchaseclient.responsecode.md)       |
| @interface     | [PurchaseClient.ProductType](/dev/tools/billing/old-version/v19/undefined-3/annotations/purchaseclient.producttype.md)         |
| @interface     | [PurchaseClient.RecurringAction](/dev/tools/billing/old-version/v19/undefined-3/annotations/purchaseclient.recurringaction.md) |
| class          | <p><a href="/pages/CqDjiKNyXVIr6PEleXOk">PurchaseClient.Builder</a></p><p>PurchaseClient 인스턴스를 쉽게 만들기 위한 빌더입니다.</p>            |

## Public methods <a href="#purchaseclient-publicmethods" id="purchaseclient-publicmethods"></a>

***

### newBuilder <a href="#purchaseclient-newbuilder" id="purchaseclient-newbuilder"></a>

```
@UiThread
public static  newBuilder(Context context)
```

PurchaseClient의 인스턴스를 만들기 위한 빌더를 생성합니다.

| **Parameters:**                                                                                            |                                              |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| context                                                                                                    | applicationContext를 사용하여 결제모듈과 연결을 위해 사용됩니다. |
| Returns:                                                                                                   |                                              |
| [PurchaseClient.Builder](/dev/tools/billing/old-version/v19/undefined-3/classes/purchaseclient.builder.md) |                                              |

### startConnection <a href="#purchaseclient-startconnection" id="purchaseclient-startconnection"></a>

```
@UiThread
public abstract void startConnection( listener)
```

PurchaseClient 설정 프로세스를 비동기적으로 시작합니다.\
완료되면 [PurchaseClientStateListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/purchaseclientstatelistener.md)를 통해 응답 받습니다.

| **Parameters:** |                                                |
| --------------- | ---------------------------------------------- |
| listener        | PurchaseClient 설정과 결제모듈 연결이 완료 되었을 때 응답을 받습니다. |

### endConnection <a href="#purchaseclient-endconnection" id="purchaseclient-endconnection"></a>

```
@UiThread
public abstract void endConnection()
```

결제 모듈과의 연결을 끊고 PurchaseClient의 보유 자원을 해제 합니다.

### launchUpdateOrInstallFlow <a href="#purchaseclient-launchupdateorinstallflow" id="purchaseclient-launchupdateorinstallflow"></a>

```
@UiThread
public abstract void launchUpdateOrInstallFlow(Activity activity,  listener)
```

IapResult.getResponseCode()의 값이 PurchaseClient.ResponseCode.RESULT\_NEED\_UPDATE가 발생했을 때\
결제 모듈의 업데이트 또는 설치를 위해 호출해야 합니다.

| **Parameters:** |                                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------------- |
| activity        | Activity: 결제 모듈의 업데이트 또는 설치의 흐름 알기위해 activity를 참조합니다.                                               |
| listener        | [IapResultListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/iapresultlistener.md) |

### launchPurchaseFlow <a href="#purchaseclient-launchpurchaseflow" id="purchaseclient-launchpurchaseflow"></a>

```
@UiThread
public abstract  launchPurchaseFlow(Activity activity,  params)
```

인앱 상품 구매를 시작합니다.\
구매화면이 표시되고 결과를 PurchaseClient 를 초기화할 때 지정했던 [PurchasesUpdatedListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/purchasesupdatedlistener.md)를 통해 응답 받습니다.

| **Parameters:**      |                                                                                                    |
| -------------------- | -------------------------------------------------------------------------------------------------- |
| activity             | Activity: 결제 흐름을 알기위해 activity를 참조합니다.                                                             |
| params               | [PurchaseFlowParams](/dev/tools/billing/old-version/v19/undefined-3/classes/purchaseflowparams.md) |
| **Returns:**         |                                                                                                    |
| <p>IapResult<br></p> |                                                                                                    |

### consumeAsync <a href="#purchaseclient-consumeasync" id="purchaseclient-consumeasync"></a>

```
@UiThread
public abstract void consumeAsync( params,  listener)
```

구매한 상품을 소비 합니다.\
소유된 상품만 수행할 수 있으며, 소비를 진행했던 상품의 경우 다시 구매를 진행해야 합니다.\
경고! API v6 부터는 구매 후 3일 이내에 소비(consume) 또는 확인(acknowledge)을 하지 않으면 환불됩니다.

| **Parameters:** |                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------- |
| params          | [ConsumeParams](/dev/tools/billing/old-version/v19/undefined-3/classes/consumeparams.md)                            |
| listener        | [ConsumeListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/consumelistener.md) 소비 작업의 결과를 전달 받습니다. |

### acknowledgeAsync <a href="#purchaseclient-acknowledgeasync" id="purchaseclient-acknowledgeasync"></a>

```
@UiThread
public abstract void acknowledgeAsync( acknowledgeParams,  listener)
```

구매한 상품을 확인 합니다.\
소유된 상품만 수행할 수 있으며, 확인을 했던 상품은 소비를 하지 않으면 재구매를 할 수 없습니다.\
관리형 상품 또는 월정액 상품에 모두 적용가능 합니다.\
특히 관리형 상품의 경우 확인(acknowledge)를 하고 일정 기간후에 소비(consume)을 진행하는 기간제 상품으로 활용할 수 있습니다.\
경고! API v6 부터는 구매 후 3일 이내에 소비(consume) 또는 확인(acknowledge)을 하지 않으면 환불됩니다.

| **Parameters:**   |                                                                                                                             |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
| acknowledgeParams | [AcknowledgeParams](/dev/tools/billing/old-version/v19/undefined-3/classes/acknowledgeparams.md)                            |
| listener          | [AcknowledgeListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/acknowledgelistener.md) 확인 작업의 결과를 전달 받습니다. |

### queryPurchasesAsync <a href="#purchaseclient-querypurchasesasync" id="purchaseclient-querypurchasesasync"></a>

```
@UiThread
public abstract void queryPurchasesAsync(String productType,  listener)
```

앱에서 구매한 모든 상품에 대한 구매정보를 가져옵니다.

| **Parameters:** |                                                                                                                                       |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| productType     | [PurchaseClient.ProductType](/dev/tools/billing/old-version/v19/undefined-3/annotations/purchaseclient.producttype.md) 상품의 타입을 지정합니다. |
| listener        | [PurchasesListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/purchaseslistener.md) 구매내역에 대한 결과를 전달 받습니다.             |

### queryProductDetailsAsync <a href="#purchaseclient-queryproductdetailsasync" id="purchaseclient-queryproductdetailsasync"></a>

```
@UiThread
public abstract void queryProductDetailsAsync( params,  listener)
```

개발자 센터에 등록한 인앱상품의 상세정보를 가져옵니다.

| **Parameters:** |                                                                                                                                        |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| params          | [ProductDetailsParams](/dev/tools/billing/old-version/v19/undefined-3/classes/productdetailsparams.md)                                 |
| listener        | [ProductDetailsListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/productdetailslistener.md) 상품 상세정보에 대한 결과를 전달 받습니다. |

### manageRecurringProductAsync <a href="#purchaseclient-managerecurringproductasync" id="purchaseclient-managerecurringproductasync"></a>

```
@UiThread
public abstract void manageRecurringProductAsync( recurringProductParams,  listener)
```

월정액 상품의 상태를 변경 합니다.\
매월 자동결제를 취소 하거나 취소한 자동결제를 다시 재개하는 동작을 진행합니다.

| **Parameters:**        |                                                                                                                                                 |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| recurringProductParams | [RecurringProductParams](/dev/tools/billing/old-version/v19/undefined-3/classes/recurringproductparams.md)                                      |
| listener               | [RecurringProductListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/recurringproductlistener.md) 월정액 상품 상태 변경에 대한 결과를 전달 받습니다. |

### launchLoginFlowAsync <a href="#purchaseclient-launchloginflowasync" id="purchaseclient-launchloginflowasync"></a>

```
@UiThread
public abstract void launchLoginFlowAsync(Activity activity,  listener)
```

IapResult.getResponseCode()의 값이 PurchaseClient.ResponseCode.RESULT\_NEED\_LOGIN가 발생했을 때 스토어 로그인을 진행합니다.

| **Parameters:** |                                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------------- |
| activity        | Activity: 스토어 로그인의 흐름 알기위해 activity를 참조합니다.                                                         |
| listener        | [IapResultListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/iapresultlistener.md) |

### getStoreInfoAsync <a href="#purchaseclient-getstoreinfoasync" id="purchaseclient-getstoreinfoasync"></a>

```
@UiThread
public abstract void getStoreInfoAsync( listener)
```

마켓 구분코드를 가져옵니다.\
이 값은 server to server API를 사용할 때 필요한 값 입니다.

| **Parameters:** |                                                                                                                       |
| --------------- | --------------------------------------------------------------------------------------------------------------------- |
| listener        | [StoreInfoListener](/dev/tools/billing/old-version/v19/undefined-3/interfaces/storeinfolistener.md) 마켓 구분코드를 전달 받습니다. |

<br>

<br>
