# Make IAP Purchases In-Game

In this guide, we will walk through how to implement the in-game purchase flow for Epic Games Store using LootLocker, from initiating a purchase to validating and granting rewards to the player.

### Prerequisites

* [A LootLocker account](https://lootlocker.com/sign-up)
* At least one created game in the [LootLocker Web Console](https://console.lootlocker.com/)
* [Epic Games Store IAP configured for your game](/commerce/real-money-purchases/how-to/epic-games-store/configure-epic-games-store-iap-settings.md)
* A [Catalog Listing configured for Epic Games Store IAP](/commerce/real-money-purchases/how-to/epic-games-store/configure-catalog-listing-epic-games-store.md)
* [LootLocker SDK integrated](/the-basics/sdks.md) into your game

### Initiate Purchase In-Game

Trigger the Epic Games Store purchase flow from within your game using the Epic Online Services Ecom Interface.

This will present the Epic Games Store checkout overlay to the player. Once the purchase is completed, Epic will return entitlement information that can be used to verify the purchase.

### Validate Purchase with LootLocker

Send the Epic entitlement information to LootLocker for validation.

LootLocker will verify the purchase with Epic Games Store to ensure it is valid before granting any rewards.

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.RedeemEpicStorePurchaseForPlayer(
    accountId: epicAccountId,
    bearerToken: epicBearerToken,
    entitlementIds: epicEntitlementIds,
    sandboxId: epicSandboxId,
    onComplete: (response) =>
    {
        if (response.success)
        {
            Debug.Log("Purchase validated and rewards granted!");
            // Refresh player data to see the granted rewards
            LootLockerSDKManager.GetPlayerData((playerResponse) =>
            {
                if (playerResponse.success)
                {
                    Debug.Log("Player data updated with new rewards");
                }
            });
        }
        else
        {
            Debug.LogError("Failed to validate purchase: " + response.errorData.message);
        }
    }
);
```

{% endtab %}

{% tab title="Unreal" %}
Coming soon
{% endtab %}
{% endtabs %}

### Grant Rewards to a Player

After successful validation, LootLocker will grant the configured rewards (Assets, Currency, Progressions) to the player.

Your game should then retrieve the updated player data to reflect the granted rewards.

### Grant Rewards to a Class

If your game uses Classes, you can grant rewards directly to those instead of the player.

This is useful for character-specific purchases or unlocks.

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.RedeemEpicStorePurchaseForClass(
    accountId: epicAccountId,
    bearerToken: epicBearerToken,
    entitlementIds: epicEntitlementIds,
    sandboxId: epicSandboxId,
    classId: playerClassId,
    onComplete: (response) =>
    {
        if (response.success)
        {
            Debug.Log("Purchase validated and rewards granted to class!");
        }
        else
        {
            Debug.LogError("Failed to validate purchase: " + response.errorData.message);
        }
    }
);
```

{% endtab %}

{% tab title="Unreal" %}
Coming soon
{% endtab %}
{% endtabs %}

### Handle Edge Cases

Make sure your implementation accounts for:

* Failed or cancelled purchases
* Pending or incomplete checkout flows
* Duplicate entitlement redemption
* Redeeming consumable entitlements after they have been granted
* Restoring or checking ownership for durable entitlements

LootLocker handles purchase validation, but your game is responsible for handling the player experience and refreshing player state after rewards are granted.

### Conclusion

You now have the full Epic Games Store purchase flow implemented: initiating a purchase using the Epic Online Services Ecom Interface, validating the entitlement through LootLocker, and granting rewards to the player.

With this setup, you can securely support Epic Games Store in-app purchases while keeping your game logic centralized through LootLocker.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/commerce/real-money-purchases/how-to/epic-games-store/make-purchases-through-epic-games-store.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
