> ## 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.

# XStoreShowRedeemTokenUIAsync

> XStoreShowRedeemTokenUIAsync

# XStoreShowRedeemTokenUIAsync

為目前使用者觸發指定權杖的兌換。

## 語法

```cpp theme={null}
HRESULT XStoreShowRedeemTokenUIAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* token,  
         const char** allowedStoreIds,  
         size_t allowedStoreIdsCount,  
         bool disallowCsvRedemption,  
         XAsyncBlock* async  
)  
```

### 參數

*storeContextHandle*   \_In\_\
類型：XStoreContextHandle

由 [XStoreCreateContext](/zh-TW/reference/system/xstore/functions/xstorecreatecontext) 傳回的使用者商店內容控制代碼。

*token*   \_In\_z\_\
類型：char\*

要兌換的權杖。此值不可為空白或 null；如果您想要顯示 UI 而不提供預先填入 UI 的代碼，請傳入單一空格 " "。

*allowedStoreIds*   \_In\_z\_count\_(allowedStoreIdsCount)\
類型：char\*\*

可讓您限制 5x5 代碼僅適用於特定產品。

*allowedStoreIdsCount*   \_In\_\
類型：size\_t

**allowedStoreIds** 中的元素數目。

*disallowCsvRedemption*   \_In\_\
類型：bool

防止兌換 CSV (禮物卡/儲值類型的 5x5 代碼)。

*async*   \_Inout\_\
類型：[XAsyncBlock\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

定義正在執行之非同步工作的 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock)。[XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 可用來輪詢呼叫的狀態並擷取呼叫結果。如需詳細資訊，請參閱 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock)。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

若要擷取此函式的執行結果，請在呼叫此函式之後呼叫 [XStoreShowRedeemTokenUIResult](/zh-TW/reference/system/xstore/functions/xstoreshowredeemtokenuiresult)。

下列程式碼片段示範啟動權杖兌換 UI 的範例。

```cpp theme={null}
void CALLBACK ShowRedeemTokenUICallback(XAsyncBlock* asyncBlock)
{
    HRESULT hr = XStoreShowRedeemTokenUIResult(asyncBlock);

    if (FAILED(hr))
    {
        printf("Failed redeem token: 0x%x\r\n", hr);
        return;
    }
}

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

    HRESULT hr = XStoreShowRedeemTokenUIAsync(
        storeContextHandle,
        token,
        nullptr,    // Can restrict to specific store IDs
        0,
        false,      // Can prevent CSV (cash gift cards)
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to request redeem token: 0x%x\r\n", hr);
        return;
    }
}


```

## 需求

**標頭：** XStore.h (包含在 XGameRuntime.h 中)

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[XStore](/zh-TW/reference/system/xstore/xstore_members)\
[XStoreShowRedeemTokenUIResult](/zh-TW/reference/system/xstore/functions/xstoreshowredeemtokenuiresult)


## Related topics

- [XStoreShowRedeemTokenUIResult](/zh-TW/reference/system/xstore/functions/xstoreshowredeemtokenuiresult.md)
- [XStore](/zh-TW/reference/system/xstore/xstore_members.md)
- [適用於 GDK 的 Unity C# API 包裝函式](/zh-TW/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [Redeem Microsoft Store Inventory Items](/api-reference/inventory/redeem-microsoft-store-inventory-items.md)
- [PFInventoryRedeemMicrosoftStoreInventoryItemsRequest](/zh-TW/services/playfab/api-references/c/pfinventorytypes/structs/pfinventoryredeemmicrosoftstoreinventoryitemsrequest.md)
