# 원격 카탈로그 가져오기

> 결제 제공업체 스토어의 원격 카탈로그를 가져옵니다.

배포한 [원격 카탈로그를](./configure-remote-catalog.md) 명시적으로 가져오기 위해 `StoreController`에 연결되는 스크립트를 생성해야 합니다. 이 스크립트를 [초기화 스크립트](./initialize-services.md)와 동일한 게임 오브젝트에 연결합니다.

결제 제공업체 스토어의 원격 카탈로그를 가져오려면`RemoteCatalogProvider`을 인스턴스화한 다음 `FetchRemoteCatalog`를 호출하여 Unity IAP 백엔드에서 제품을 가져와야 합니다.

그런 다음 `RemoteCatalogProvider`를 사용하여 직접 `FetchProducts`를 호출하거나 `IProductService` 또는 `StoreController`에서 제품 목록을 `FetchProducts`에 전달할 수 있습니다.

## 레퍼런스 정보##reference-information

다음 요소는 결제 제공업체의 원격 카탈로그를 가져올 때 관련이 있습니다.

| **파라미터**                | **설명**                                                                                                                                   |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `RemoteCatalogProvider` | IAP와 함께 사용할 원격 카탈로그를 가져오는 데 사용되는 클래스입니다. 원격 카탈로그는 IAP 백엔드에서 얻습니다.                                                                        |
| `UnityIAPServices`      | IAP와의 커뮤니케이션을 위한 시작점입니다. 다음 서비스가 필요합니다.  `StoreService` `ProductService` `PurchaseService`                                               |
| `StoreController`       | 이것은 `UnityIAPServices`에 래퍼입니다. 단일 클래스와 상호작용하는 것을 선호하는 경우, 생성자에 `storeName`를 전달합니다.                                                       |
| `PaymentProvider.Name`  | 이 식별자는 `UnityIAPServices` 및 `StoreController`에서 D2C(Direct-to-Consumer) 결제 제공업체를 등록하는 데 사용됩니다. 이 필드는 구성 목적으로 사용되며 제공자의 표시 이름을 반환하지 않습니다. |

> **Important:**
>
> `RemoteCatalogProvider`에 통화를 할 때 정확한 상점 이름을 지정해야 합니다. D2C 결제 제공업체의 경우 `PaymentProvider.Name`입니다.

## 원격 카탈로그 가져오기 예제 스크립트##fetch-remote-catalog-example-script

다음 예제 스크립트를 참고하십시오.

```csharp
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. RemoteCatalogProvider 초기화
        RemoteCatalogProvider catalogProvider = new RemoteCatalogProvider();

        // 2. 결제 제공업체에 대해 명시적으로 카탈로그를 가져옵니다.
        var fetchRemoteCatalogResult = await catalogProvider.FetchRemoteCatalog();

        if (!fetchRemoteCatalogResult.Success)
            fetchRemoteCatalogResult.Exception!;을 발생시킵니다.

        // 3. 원격 정의를 StoreController에 전달합니다.
        var productDefinitions = catalogProvider.GetProducts();
        m_StoreController.FetchProducts(productDefinitions);
    }

    private void OnPurchasePending(PendingOrder 순서)
    {
        // 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(제품의 각 제품)
        {
            Foreach (produ.catalogListings.Values의 var catalogListing)
            {
                Debug.Log($"ID: {catalogListing.definition.id} - Price: {catalogListing.metadata.localizedPriceString}");
            }
        }
    }
}
```

## 다음 단계##next-steps

이 페이지는 IAP를 사용하여 D2C 결제 제공업체를 설정하는 워크플로의 일부입니다. 이 워크플로를 계속하려면 다음 옵션 중 하나를 선택합니다.

[Integrate D2C payment providers](./workflow.md#fetch-your-remote-catalog): Integrate D2C payment providers with IAP 워크플로 페이지로 돌아갑니다.
[Configure a webhook for purchase fulfillment](./configure-fulfilment.md): 워크플로의 다음(선택) 단계로 이동하여 D2C 결제 제공업체를 설정합니다.
