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

# XStoreReportConsumableFulfillmentAsync

> XStoreReportConsumableFulfillmentAsync

# XStoreReportConsumableFulfillmentAsync

消耗指定數量的消費性產品。如需實作和使用消費性產品的詳細資訊，請參閱[以消費性產品為基礎的生態系統](/zh-TW/publishing/xstore-commerce/xstore-consumables)。

## 語法

```cpp theme={null}
HRESULT XStoreReportConsumableFulfillmentAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeProductId,  
         uint32_t quantity,  
         GUID trackingId,  
         XAsyncBlock* async  
)  
```

### 參數

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

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

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

您要回報為已履行之消費性附加元件的市集識別碼。

*quantity*   \_In\_\
類型：uint32\_t

您要回報為已履行之消費性附加元件的單位數目。對於市集管理的消費性產品 (也就是由 Microsoft 追蹤餘額的消費性產品)，請指定已消耗的單位數目。對於遊戲管理的消費性產品 (也就是由開發人員追蹤餘額的消費性產品)，請指定 1。

*trackingId*   \_In\_\
類型：GUID

開發人員提供的 GUID，可識別與履行作業相關聯的特定交易，以供追蹤之用。

*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 成功或錯誤碼。

## 備註

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

下列程式碼片段示範使用某個數量之消費性產品的範例。

```cpp theme={null}
void CALLBACK ReportConsumableFulfillmentCallback(XAsyncBlock* asyncBlock)
{
    XStoreConsumableResult result{};
    HRESULT hr = XStoreReportConsumableFulfillmentResult(
        asyncBlock,
        &result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the consumable balance remaining: 0x%x\r\n", hr);
        return;
    }

    printf("quantity: %d\r\n", result.quantity);
}

void ReportConsumableFulfillment(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* storeId, uint32_t quantity, GUID trackingId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = ReportConsumableFulfillmentCallback;

    HRESULT hr = XStoreReportConsumableFulfillmentAsync(
        storeContextHandle,
        storeId,
        quantity,
        trackingId,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to report consumable fulfillment: 0x%x\r\n", hr);
        return;
    }
}
```

## 需求

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

**程式庫：** xgameruntime.lib

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

## 概念文件

* [以消費性產品為基礎的生態系統](/zh-TW/publishing/xstore-commerce/xstore-consumables)

## 另請參閱

[XStore](/zh-TW/reference/system/xstore/xstore_members)\
[以消費性產品為基礎的生態系統](/zh-TW/publishing/xstore-commerce/xstore-consumables)
[XStoreReportConsumableFulfillmentResult](/zh-TW/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult)


## Related topics

- [XStoreReportConsumableFulfillmentAsync](/reference/system/xstore/functions/xstorereportconsumablefulfillmentasync.md)
- [XStoreReportConsumableFulfillmentResult](/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult.md)
