Fetch your Remote Catalog
Fetch your Remote Catalog for a payment provider store.
Read time 2 minutesLast updated a month ago
You need to create a script that connects to the to explicitly fetch the Remote Catalog you deployed. Attach this script to the same GameObject as the initialization script.
StoreControllerTo fetch the Remote Catalog for a payment provider store, you need to instantiate the and then make a call to to retrieve the products from the Unity IAP backend.
RemoteCatalogProviderFetchRemoteCatalogYou can then either use the directly to call or you can pass the product list to the from the or .
RemoteCatalogProviderFetchProductsFetchProductsIProductServiceStoreControllerReference information
The following elements are relevant when you fetch the Remote Catalog for payment providers:
Parameter | Description |
|---|---|
| This is the class used to obtain the Remote Catalog to use along with IAP. The Remote Catalog is obtained from the IAP backend. |
| This is the starting point to communicate with IAP. You need to get the following services:
|
| This is a wrapper over |
| This is an identifier used to register a Direct-to-Consumer (D2C) payment provider with |
Fetch Remote Catalog example script
Refer to the following example script:
using System.Collections.Generic;using System.Threading.Tasks;using UnityEngine;using UnityEngine.Purchasing;public class PurchaseManager : MonoBehaviour{ StoreController m_StoreController; // Called by the ServiceOrchestrator after Auth is complete public async Task InitializeIAP() { m_StoreController = UnityIAPServices.StoreController(PaymentProvider.Name); m_StoreController.OnPurchasePending += OnPurchasePending; await m_StoreController.Connect(); m_StoreController.OnProductsFetched += OnProductsFetched; // 1. Initialize the RemoteCatalogProvider RemoteCatalogProvider catalogProvider = new RemoteCatalogProvider(); // 2. Fetch the catalog explicitly for the Payment Provider var fetchRemoteCatalogResult = await catalogProvider.FetchRemoteCatalog(); if (!fetchRemoteCatalogResult.Success) throw fetchRemoteCatalogResult.Exception!; // 3. Pass the remote definitions to the StoreController var productDefinitions = catalogProvider.GetProducts(); m_StoreController.FetchProducts(productDefinitions); } private void OnPurchasePending(PendingOrder order) { // Handle purchase validation and rewarding before confirming the order Debug.Log($"Order pending: {order.Info}"); } void OnProductsFetched(List<Product> products) { // Handle fetched products (e.g., populate UI) Debug.Log("Fetched products:"); foreach (var product in products) { foreach (var catalogListing in product.catalogListings.Values) { Debug.Log($"ID: {catalogListing.definition.id} - Price: {catalogListing.metadata.localizedPriceString}"); } } }}
Next steps
This page is part of a workflow to set up D2C payment providers with IAP. To continue this workflow, choose one of the following options: