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

# 启用 XStore 开发与测试

> 为 XStore API 开发和沙盒中的测试设置你的 XBOX 产品，包括权益、授权和测试账户要求。

游戏使用 [XStore API](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md) 对与你的游戏及相关产品（例如附加内容）关联的许可证和权益执行操作。许多 `XStore` 操作会操纵由 Microsoft Store 服务管理的关于你游戏的信息。

> [!NOTE]
>
> 此页面相较于以前版本已进行了大量更新。

自 2023 年 6 月起，大多数[\*](#exceptions) `XStore` API 测试不再需要将构建设置为可授权（例如 contentIdOverride），并且不再需要每个账号都拥有该游戏的权益。

在开发沙盒中测试商务时，单个测试账户上的所有购买都必须在同一个沙盒中完成。将测试账户切换到另一个沙盒并购买更多物品会导致两个沙盒中该账号的查询结果异常。这是因为购买的许可证和信息与单个账号首次购买该物品时所在的沙盒绑定。

在 PC 上的开发沙盒中测试商务时，确保登录 Microsoft Store 应用和 XBOX 应用的账号相同。当处于沙盒中时，Microsoft Store 中物品使用的凭据与 XBOX 账户特定绑定。这对于确保所有操作与专门发布到当前活跃沙盒中的产品交互至关重要。有关更多信息，请参阅[在 PC 上处理商店账号不匹配的场景](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-mismatched-accounts.md)。

若要测试大多数[\*](#exceptions) `XStore` API，请确保 game config 包含来自 Partner Center 的正确值。

* **与授权相关的 API，例如 [XStoreQueryGameLicenseAsync](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)，需要完全授权的上下文才能正常工作。** 有关完整详情，请参阅[启用授权测试](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)。

## 将游戏 ID 应用到 MicrosoftGameConfig

首先，在[Partner Center](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-initial-configuration.md)发布你的游戏和附加内容。

然后在游戏的配置文件中确保这些值与你配置的游戏匹配：

```xml theme={null}
  <Identity
    Name="41336MicrosoftATG.InGameStoreXS"
    Publisher="CN=A4954634-DF4B-47C7-AB70-D3215D246AF1"
    Version="2023.5.5.0" />
  <StoreId>9NTL0QDWZ4FS</StoreId>
  <MSAAppId>000000004C2690C8</MSAAppId>
  <TitleId>62ab3c24</TitleId>
```

### Identity

位于 Partner Center 的 **Game setup > Identity details** 下。

在 PC 上：严格要求与在 Partner Center 为你的游戏分配的内容匹配。

对主机而言不强制要求，但在创建包以提交到 Partner Center 时应进行检查。

`Identity` 节点中的 `Name` 需要与 **Package/Identity/Name** 匹配；`Identity` 节点中的 `Publisher` 需要与 **Package/Identity/Publisher** 匹配。

![Game setup > Identity details，Package/Identity/Name 和 Publisher 被圈出](https://mintcdn.com/microsoft-4404708b/iADzli99B7EWodAv/images/xstore/identitydetails_appidentity.png?fit=max\&auto=format\&n=iADzli99B7EWodAv\&q=85\&s=f0f690902c8867bbae062a337589d182)

### StoreID

也位于 **Game setup > Identity details** 中。

![Game setup > Identity details，URL 和页面中的 StoreId 被圈出](https://mintcdn.com/microsoft-4404708b/iADzli99B7EWodAv/images/xstore/identitydetails_storeid.png?fit=max\&auto=format\&n=iADzli99B7EWodAv\&q=85\&s=1902ced5d2643fa8c1de30281ef96723)

## 参考 API 文档

* [XStore（API 内容）](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)
  * 函数
    * [XStoreQueryGameLicenseAsync](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)

## 另请参阅

[商务概述](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-commerce-overview.md)

[Partner Center 的初始配置](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-initial-configuration.md)

[启用授权测试](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)

[正确切换沙盒以进行 Store 操作](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-switching-sandbox.md)

[XStore API 参考](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)


## Related topics

- [启用授权测试](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)
- [排查 XStore 开发问题](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-troubleshooting.md)
- [为游戏实现试玩](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-trials.md)
- [商店基本操作](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-basic-operations.md)
- [检查更新](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-checking-updates.md)
