Documentation

Support

In-App Purchasing

In-App Purchasing

Use Google Play billing extensions

Learn how to integrate Google Play-specific extensions with Unity IAP to enhance purchase handling and subscription management.
Read time 1 minuteLast updated 5 hours ago

Access Google Play-specific extensions for Unity IAP. Use obfuscated account and profile IDs for fraud prevention and account linking, and listen for deferred subscription payment changes when users modify their subscription tier.

Extended functionality

Learn how to use Google Play-specific features with Unity IAP.

Set and read obfuscated IDs

Use obfuscated account and profile IDs to associate purchases with user accounts while protecting user privacy. These identifiers help with fraud detection and can link purchases to your backend user system.
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, Order order) { var googlePlayPurchasingService = storeController.GooglePlayStoreExtendedPurchaseService; if (googlePlayPurchasingService != null) { var obfuscatedProfileId = googlePlayPurchasingService.GetObfuscatedProfileId(order); var obfuscatedAccountId = googlePlayPurchasingService.GetObfuscatedAccountId(order); //... } } static void ReadObfuscatedIdsFromOrder(Order order) { var profileId = order.Info.Google?.ObfuscatedProfileId; var accountId = order.Info.Google?.ObfuscatedAccountId; }}

Listen for deferred subscription changes

When a user changes their subscription tier (upgrade or downgrade) with a deferred payment, the change takes effect at the next renewal date. Use this listener to be notified when such changes occur, so you can update your UI or inform the user about their pending subscription change.
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; //... }}