Initiate a purchase
Start a purchase from your application and let players choose how to pay with the Purchase Options UI.
Read time 4 minutesLast updated 3 hours ago
When a player chooses to buy a product, you start the purchase from your application with the Unity In-App Purchasing (IAP) SDK. It's recommended to use the Purchase Options UI, an in-game component that presents the player with the payment options they're eligible for, such as the native store, a payment provider, or your webshop. The Purchase Options UI is the default integration path for Direct to Consumer (D2C) payments. To show it, you call a single method with the listing you want to sell, and the UI presents the payment options your routing rules return for that player. You don't build the interface yourself. If a project hasn't configured a payment provider, its purchase behavior doesn't change. If you want to present your own purchase interface instead, you can build a custom UI and consume the routing output directly.
Prerequisites
Before you initiate a purchase through the Purchase Options UI, complete the following steps:- Create and fetch your Remote Catalog.
- Initialize the IAP services and connect to the store.
- To surface D2C options, connect at least one payment provider and add a routing rule that applies to the player.
Start a purchase from your application
To start a purchase and show the Purchase Options UI, callShowPurchaseOptionIPaymentOptionProvidercatalogListingIdcatalogListingIdcatalogListingIdIPaymentOptionProviderIPaymentProvidersExtendedServiceGetPaymentOptionProviderUGUI()GetPaymentOptionProviderUITK()When the player completes the purchase, the SDK invokes thepublic async void BuyProduct(string catalogListingId){ // Show the Purchase Options UI with the payment options the player is eligible for. await m_PaymentOptionProvider.ShowPurchaseOption(catalogListingId);}
OnPurchasePendingCheck eligibility before you show the UI
Unity doesn't evaluate your compliance or eligibility rules before it shows the Purchase Options UI. If you show the UI to a player who isn't eligible for D2C payments and your compliance check later returnsfalseIsUserEligibleForPurchaseIPaymentProvidersExtendedServicePurchaseProductvar m_PaymentProviderStoreController = new StoreController(PaymentProvider.Name);var m_PaymentProviderStoreExtendedService = m_PaymentProviderStoreController.PaymentProviderStoreExtendedService;// Obtain the Payment Option Provider. Use GetPaymentOptionProviderUITK if your project uses UI Toolkit.var m_PaymentOptionProvider = m_PaymentProviderStoreExtendedService?.GetPaymentOptionProviderUGUI();public async void BuyProduct(string catalogListingId){ if (await m_PaymentProviderStoreExtendedService.IsUserEligibleForPurchase()) { // Show the Purchase Options UI with the eligible payment options. m_PaymentOptionProvider.ShowPurchaseOption(catalogListingId); } else { // The player isn't eligible for D2C payment options. Process the native purchase directly. m_PaymentProviderStoreController.PurchaseProduct(catalogListingId); }}
What the Purchase Options UI presents

- Native (the Apple App Store or Google Play Store), which is always present.
- A payment provider, surfaced through your routing rules. The UI displays the highest-priority eligible provider; any remaining providers act as fallbacks and aren't shown.
- A webshop entry point, surfaced when your project has Unity Webshop configured and a routing rule opts into in-game webshop surfacing.
Incentives
If you configure an incentive for a payment provider or webshop option, such as a bonus value, sale price, or time-limited offer, the Purchase Options UI displays it. Configure incentives through the SKU fields in your catalog. Where the same SKU appears both in the Purchase Options UI and in your webshop, the UI uses a consistent visual treatment so players recognize it as the same incentive.Provider memory
After a player completes a successful purchase, the SDK records the provider they used on that device. On subsequent purchases, the UI presents that provider as the default action, while keeping the other eligible providers available. The player can always select a different provider.Disable the UI for a build
Even when you callShowPurchaseOptionBuild your own purchase UI
The Purchase Options UI is optional. To present your own interface, consume the routing output directly through the SDK and skip the default UI:- Call to get the ordered list of providers the player is eligible for.
IPaymentProvidersExtendedService.GetEligiblePaymentProviders() - Call to force a specific provider for the purchase.
IPaymentProvidersExtendedPurchaseService.SetPaymentProviderOverride(string)