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

# XStoreShowGiftingUIAsync

> XStoreShowGiftingUIAsync

Begins the UI overlay for purchasing the specified product as a gift for another user. The current user will be prompted to enter information about the recipient of the gift and will be guided through the purchase flow.

## Syntax

```cpp theme={null}
HRESULT XStoreShowGiftingUIAsync(  
         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 as a gift. **Note**: this product must configured to support gifting purchases.

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

Name of the product to purchase as a gift.

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

A json blob that is handed to the purchase gift 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

The product to be purchased as a gift must be configured to support gifting purchases. To retrieve the list of products that support gifting call [XStoreQueryProductsAsync](https://docs.xbox.com/reference/system/xstore/functions/xstorequeryproductsasync.md) with the `actionFilters` parameter set to `"Gift"`.

To retrieve the result of this function call [XStoreShowGiftingUIResult](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowgiftinguiresult.md) after calling this function. This function should only be called when the user has chosen to purchase something as a gift, 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 gift purchase for a particular store product.

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

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

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

    HRESULT hr = XStoreShowGiftingUIAsync(
        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

## See also

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


## Related topics

- [XStoreShowGiftingUIResult](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowgiftinguiresult.md)
- [XStore (API contents)](https://docs.xbox.com/reference/system/xstore/xstore_members.md)
- [XStoreShowPurchaseUIAsync](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowpurchaseuiasync.md)
- [XStoreShowProductPageUIAsync](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowproductpageuiasync.md)
- [XStoreShowRateAndReviewUIAsync](https://docs.xbox.com/reference/system/xstore/functions/xstoreshowrateandreviewuiasync.md)
