# Google Play 과금 확장 기능 사용

> Google Play 전용 확장 기능을 Unity IAP와 연동하여 구매 처리 및 구독 관리를 향상하는 방법을 알아봅니다.

Unity IAP 관련 Google Play 관련 확장 기능에 액세스합니다. 사기 방지 및 계정 연결을 위해 난독 계정 및 프로필 ID를 사용하고 사용자가 구독 티어를 수정할 때 디퍼드 구독 결제 변경 사항을 수신합니다.

## 확장 기능##extended-functionality

Google Play 전용 기능을 Unity IAP와 함께 사용하는 방법을 알아봅니다.

### 난독화된 ID 설정 및 읽기##set-and-read-obfuscated-ids

사용자 개인정보 보호를 위해 난독화된 계정 및 프로필 ID를 사용하여 구매를 사용자 계정과 연결합니다. 이러한 식별자는 부정 행위 감지에 도움이 되며 구매를 백엔드 사용자 시스템에 연결할 수 있습니다.

> **Note:**
>
> 난독화된 ID는 [`IGooglePlayStoreExtendedService`](https://docs.unity3d.com/Packages/com.unity.purchasing@latest?subfolder=/api/UnityEngine.Purchasing.IGooglePlayStoreExtendedService.html)를 사용하여 설정되지만 [`IGooglePlayStoreExtendedPurchaseService`](https://docs.unity3d.com/Packages/com.unity.purchasing@latest?subfolder=/api/UnityEngine.Purchasing.IGooglePlayStoreExtendedPurchaseService.html)를 사용하여 순서에서 읽습니다.

```cs
using UnityEngine.Purchasing;

class GooglePlayObfuscatedIdsSample
{
    static void SetObfuscatedIds(StoreController storeController, string profileId, string accountId)
    {
        var googlePlayStoreService = storeController.GooglePlayStoreExtendedService;
        if (googlePlayStoreService != null)
        {
            googlePlayStoreService.SetObfuscatedProfileId(profileId);
            googlePlayStoreService.SetObfuscatedAccountId(accountId);
        }
    }
    
    static void ReadObfuscatedIdsUsingConvenienceFunction(StoreController storeController, 주문 순서)
    {
        var googlePlayPurchasingService = storeController.GooglePlayStoreExtendedPurchaseService;
        if (googlePlayPurchasingService != null)
        {
            var obfuscatedProfileId = googlePlayPurchasingService.GetObfuscatedProfileId(order);
            var obfuscatedAccountId = googlePlayPurchasingService.GetObfuscatedAccountId(order);
            //...
        }
    }

    static void ReadObfuscatedIdsFromOrder(정렬 순서)
    {
        var profileId = order.Info.Google?.ObfuscatedProfileId;
        var accountId = order.Info.Google?.ObfuscatedAccountId;
    }
}
```

### 디퍼드 구독 변경 사항 수신##listen-for-deferred-subscription-changes

사용자가 디퍼드 결제로 구독 티어(업그레이드 또는 다운그레이드)를 변경하면 다음 갱신 날짜에서 변경 사항이 적용됩니다. 이러한 변경 사항이 발생하면 이 리스너를 사용하여 UI를 업데이트하거나 사용자에게 보류 중인 구독 변경 사항을 알릴 수 있습니다.

```cs
using UnityEngine.Purchasing;

class AddGoogleEventListenersSample
{
    void AddGoogleEventListeners(StoreController storeController)
    {
        var googlePlayPurchasingService = storeController.GooglePlayStoreExtendedPurchaseService;
        if (googlePlayPurchasingService != null)
        {
            googlePlayPurchasingService.OnDeferredPaymentUntilRenewalDate += OnDeferredPaymentUntilRenewalDate;
        }
    }

    void OnDeferredPaymentUntilRenewalDate(DeferredPaymentUntilRenewalDateOrder deferredPaymentOrder)
    {
        var currentOrder = deferredPaymentOrder.CurrentOrder;
        var nextSubscriptionProduct = deferredPaymentOrder.SubscriptionOrdered;
        //...
    }
}
```
