> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XStoreGetUserPurchaseIdAsync

> XStoreGetUserPurchaseIdAsync

# XStoreGetUserPurchaseIdAsync

고객 구매 ID를 가져옵니다. 이 ID는 현재 사용자를 대신하여 무료 제품에 대한 자격을 부여하는 데 사용할 수 있는 Microsoft Store ID 키를 검색합니다. 이 API는 [서비스에서 제품 관리](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/service-to-service/service-to-service-nav)에 설명된 흐름에서 사용됩니다.

## 구문

```cpp theme={null}
HRESULT XStoreGetUserPurchaseIdAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* serviceTicket,  
         const char* publisherUserId,  
         XAsyncBlock* async  
)  
```

### 매개 변수

*storeContextHandle*   \_In\_\
형식: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)가 반환한 사용자의 스토어 컨텍스트 핸들입니다.

*serviceTicket*   \_In\_z\_\
형식: char\*

구매와 연관된 서비스 티켓입니다.

*publisherUserId*   \_In\_z\_\
형식: char\*

게시자 사용자 ID가 포함된 문자열입니다.

*async*   \_Inout\_\
형식: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

수행 중인 비동기 작업을 정의하는 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)입니다. [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)을 사용하여 호출의 상태를 폴링하고 호출 결과를 검색할 수 있습니다. 자세한 내용은 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)을 참조하세요.

### 반환 값

형식: HRESULT

HRESULT 성공 또는 오류 코드입니다.

## 설명

고객의 구매 ID와 이 함수의 실행 결과를 검색하려면 이 함수를 호출한 후 [XStoreGetUserPurchaseIdResult](/reference/system/xstore/functions/xstoregetuserpurchaseidresult)를 호출합니다. 고객의 구매 ID 크기를 검색하려면 이 함수를 호출한 후 [XStoreGetUSerPurchaseIdResultSize](/reference/system/xstore/functions/xstoregetuserpurchaseidresultsize)를 호출합니다. 결과 크기를 알면 결과를 더 효율적으로 읽을 수 있습니다.

다음 코드 조각은 고객 구매 ID를 검색하는 예를 보여 줍니다.

```cpp theme={null}
void CALLBACK GetUserPurchaseIdCallback(XAsyncBlock* asyncBlock)
{
    size_t size;
    HRESULT hr = XStoreGetUserPurchaseIdResultSize(
        asyncBlock,
        &size);

    if (FAILED(hr))
    {
        printf("Failed retrieve the user purchase ID size: 0x%x\r\n", hr);
        return;
    }

    char* result = new char[size];
    hr = XStoreGetUserPurchaseIdResult(
        asyncBlock,
        size,
        result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the user purchase ID result: 0x%x\r\n", hr);
        delete[] result;
        return;
    }

    printf("result: %s\r\n", result);

    delete[] result;
}

void GetUserPurchaseId(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* serviceTicket, const char* publisherUserId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;

    asyncBlock->callback = GetUserPurchaseIdCallback;

    HRESULT hr = XStoreGetUserPurchaseIdAsync(
        storeContextHandle,
        serviceTicket,
        publisherUserId,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get user purchase ID: 0x%x\r\n", hr);
        return;
    }
}
```

## 요구 사항

**헤더:** XStore.h(XGameRuntime.h에 포함됨)

**라이브러리:** xgameruntime.lib

**지원 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## 개념 설명서

* [Requesting a User Store ID for service-to-service authentication](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/service-to-service/xstore-requesting-a-userstoreid)

## 참고 항목

[XStore](/reference/system/xstore/xstore_members)\
[XStoreGetUserPurchaseIdResult](/reference/system/xstore/functions/xstoregetuserpurchaseidresult)\
[XStoreGetUSerPurchaseIdResultSize](/reference/system/xstore/functions/xstoregetuserpurchaseidresultsize)\
[Manage products from your services](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/service-to-service/service-to-service-nav)


## Related topics

- [XStoreGetUserPurchaseIdResult](/ko/reference/system/xstore/functions/xstoregetuserpurchaseidresult.md)
- [XStoreGetUserPurchaseIdResultSize](/ko/reference/system/xstore/functions/xstoregetuserpurchaseidresultsize.md)
- [서비스 간 인증을 위한 User Store ID 요청](/ko/publishing/xstore-commerce/xstore-requesting-userstoreid.md)
- [XStore 커머스 개요](/ko/publishing/xstore-commerce/xstore-commerce-overview.md)
- [XStore](/ko/reference/system/xstore/xstore_members.md)
