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

# XStoreReportConsumableFulfillmentAsync

> XStoreReportConsumableFulfillmentAsync

# XStoreReportConsumableFulfillmentAsync

消耗指定数量的消耗品。有关实现和使用消耗品产品的详细信息，请参阅[基于消耗品的生态系统](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-consumables.md)。

## 语法

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

### 参数

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

[XStoreCreateContext](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstorecreatecontext.md) 为用户返回的商店上下文句柄。

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

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

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

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

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

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

*async*   \_Inout\_\
类型：[XAsyncBlock\*](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)

定义正在完成的异步工作的 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)。[XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md) 可用于轮询调用的状态并检索调用结果。有关详细信息，请参阅 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)。

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

## 备注

要检索此函数调用的结果，请在调用此函数之后调用 [XStoreReportConsumableFulfillmentResult](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult.md)。

以下代码片段展示了使用一定数量的消耗品的示例。

```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://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-consumables.md)

## 另请参阅

[XStore](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)\
[基于消耗品的生态系统](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-consumables.md)
[XStoreReportConsumableFulfillmentResult](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstorereportconsumablefulfillmentresult.md)


## Related topics

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