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

# XStoreShowPurchaseUIAsync

> XStoreShowPurchaseUIAsync

# XStoreShowPurchaseUIAsync

指定した製品の購入 UI オーバーレイを開始します。

## Syntax

```cpp theme={null}
HRESULT XStoreShowPurchaseUIAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeId,  
         const char* name,  
         const char* extendedJsonData,  
         XAsyncBlock* async  
)  
```

### Parameters

*storeContextHandle*   \_In\_\
型: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) によって返されたユーザーのストア コンテキスト ハンドル。

*storeId*   \_In\_z\_\
型: char\*

購入する製品の ID。

*name*   \_In\_opt\_z\_\
型: char\*

購入する製品の名前。

*extendedJsonData*   \_In\_opt\_z\_\
型: char\*

購入フローに渡される JSON ブロブ。カスタム キャンペーン ID を挿入できるため、購入の開始経路を追跡できます。

*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) を参照してください。

### Return value

型: HRESULT

HRESULT の成功またはエラー コード。

## Remarks

> !\[NOTE] この操作では、購入が想定されている場合でも、その後にアイテムのダウンロードやインストールは行われません。このコンテンツをダウンロードおよびインストールしたい場合は、購入が成功した後に [XStoreDownloadAndInstallPackagesAsync](/reference/system/xstore/functions/xstoredownloadandinstallpackagesasync) を呼び出すことをお勧めします。ユーザーに追加のプロンプトは表示されません。

> !\[NOTE] PC では、購入が成功した後に表示される購入確認ダイアログの上部に閉じるボタン \[X] が表示されます。\[OK] の代わりにこれを選択すると `XStoreShowPurchaseUIResult` に E\_ABORT が返され、意図しない結果になる可能性があります。これはダイアログがこの方法で閉じられたときの Windows の標準動作です。

この関数の結果を取得するには、この関数を呼び出した後に [XStoreShowPurchaseUIResult](/reference/system/xstore/functions/xstoreshowpurchaseuiresult) を呼び出します。この関数は、ユーザーが何かを購入することを選択したときにのみ呼び出す必要があり、支払い情報とユーザーの確認をプロセス外で処理するモーダル購入ダイアログをシステムに表示させます。

次のコード スニペットは、特定のストア製品の購入を要求する例を示しています。

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

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

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

    HRESULT hr = XStoreShowPurchaseUIAsync(
        storeContextHandle,
        storeId,
        nullptr,    // Can be used to override the title bar text
        nullptr,    // Can be used to provide extra details to purchase
        asyncBlock.get());

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

## Requirements

**ヘッダー:** XStore.h (XGameRuntime.h に含まれる)

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## Conceptual documentation

* [ゲームでゲーム内購入を実装する](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-services/e2e-in-game-purchases)
* [基本的なストア操作](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)
* [ダウンロード可能なコンテンツ (DLC) の管理およびライセンス](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)
* [XStore 開発のトラブルシューティング](/publishing/xstore-commerce/xstore-troubleshooting)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreShowPurchaseUIResult](/reference/system/xstore/functions/xstoreshowpurchaseuiresult)


## Related topics

- [XStoreShowPurchaseUIResult](/ja-jp/reference/system/xstore/functions/xstoreshowpurchaseuiresult.md)
- [XStore 開発のトラブルシューティング](/ja-jp/publishing/xstore-commerce/xstore-troubleshooting.md)
- [基本的な Store 操作](/ja-jp/publishing/xstore-commerce/xstore-basic-operations.md)
- [オプション サービス](/ja-jp/build/gdk-and-engines/optional-services.md)
- [XStore](/ja-jp/reference/system/xstore/xstore_members.md)
