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

# XStoreShowPurchaseUIAsync

> XStoreShowPurchaseUIAsync

Begins the purchase UI overlay for the specified product.

## Syntax

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

### Parameters

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

The store context handle for the user returned by [XStoreCreateContext](https://docs.xbox.com/reference/system/xstore/functions/xstorecreatecontext.md).

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

ID for the product to purchase.

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

Name of the product to purchase.

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

A json blob that is handed to the purchase flow. Allows for insertion of custom campaign IDs, so you can track how the purchase started.

*async*   \_Inout\_\
Type: [XAsyncBlock\*](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)

An [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) defining the asynchronous work being done. The [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) can be used to poll for the call's status and retrieve call results. See [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) for more information.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

> !\[NOTE] This operation does not trigger the download or installation of the items after an expected purchase. If you wish to download and install this content, it is recommended to call [XStoreDownloadAndInstallPackagesAsync](https://docs.xbox.com/reference/system/xstore/functions/xstoredownloadandinstallpackagesasync.md) after a successful purchase. No additional prompts will be given to the user.

> !\[NOTE] On PC, the purchase confirmation dialog that shows after a successful purchase will have a close button \[X] at top. Selecting this instead of Ok will result in E\_ABORT returned to `XStoreShowPurchaseUIResult`, which may not be desired. This is standard Windows behaviour when any dialog is closed in this way.

To retrieve the result of this function call [XStoreShowPurchaseUIResult](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowpurchaseuiresult.md) after calling this function. This function should only be called when the user has chosen to purchase something, and will cause the system to present a modal purchase dialog that handles payment information and user confirmation out-of-process.

The following code snippet shows an example of requesting a purchase for a particular store product.

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

**Header:** XStore.h (included in XGameRuntime.h)

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Implement in-game purchases in your game](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-services/e2e-in-game-purchases)
* [Basic store operations](https://docs.xbox.com/publishing/xstore-commerce/xstore-basic-operations.md)
* [Manage and license downloadable content (DLC)](https://docs.xbox.com/publishing/xstore-commerce/xstore-dlc.md)
* [Troubleshooting XStore development](https://docs.xbox.com/publishing/xstore-commerce/xstore-troubleshooting.md)

## See also

[XStore](https://docs.xbox.com/reference/system/xstore/xstore_members.md)\
[XStoreShowPurchaseUIResult](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowpurchaseuiresult.md)


## Related topics

- [XStoreShowPurchaseUIResult](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowpurchaseuiresult.md)
- [Troubleshooting XStore development](https://docs.xbox.com/publishing/xstore-commerce/xstore-troubleshooting.md)
- [Basic store operations](https://docs.xbox.com/publishing/xstore-commerce/xstore-basic-operations.md)
- [Optional services](https://docs.xbox.com/build/gdk-and-engines/optional-services.md)
- [XStore (API contents)](https://docs.xbox.com/reference/system/xstore/xstore_members.md)
