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

消耗指定数量的消耗品。有关实现和使用消耗品产品的详细信息，请参阅[基于消耗品的生态系统](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-consumable-based-ecosystems)。

## 语法

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

### 参数

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

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) 为用户返回的商店上下文句柄。

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

要报告为已履行的消耗品加载项的商店 ID。

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

要报告为已履行的消耗品加载项的单位数量。对于商店托管的消耗品（即由 Microsoft 跟踪余额的消耗品），请指定已消耗的单位数量。对于游戏托管的消耗品（即由开发人员跟踪余额的消耗品），请指定 1。

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

由开发人员提供的 GUID，用于标识与履行操作关联的特定事务，以便进行跟踪。

*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 成功或错误代码。

## 备注

要检索此函数调用的结果，请在调用此函数之后调用 [XStoreReportConsumableFulfillmentResult](/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 主机

## 概念文档

* [基于消耗品的生态系统](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-consumable-based-ecosystems)

## 另请参阅

[XStore](/reference/system/xstore/xstore_members)\
[基于消耗品的生态系统](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-consumable-based-ecosystems)
[XStoreReportConsumableFulfillmentResult](/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult)


## Related topics

- [XStoreReportConsumableFulfillmentResult](/zh-CN/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult.md)
- [XStoreConsumableResult](/zh-CN/reference/system/xstore/structs/xstoreconsumableresult.md)
- [基于消耗品的生态系统](/zh-CN/publishing/xstore-commerce/xstore-consumables.md)
- [可选服务](/zh-CN/build/gdk-and-engines/optional-services.md)
- [XStore](/zh-CN/reference/system/xstore/xstore_members.md)
