# Make IAP Purchases In-Game

In this guide, we will walk through how to implement the in-game purchase flow for PlayStation 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/)
* [PlayStation Store IAP configured for your game](/commerce/real-money-purchases/how-to/playstation-store/configure-playstation-iap-settings.md)
* A [Catalog Listing configured for PlayStation Store IAP](/commerce/real-money-purchases/how-to/playstation-store/configure-catalog-listing-playstation-store.md)
* [LootLocker SDK integrated](/the-basics/sdks.md) into your game

### Initiate Purchase In-Game

Trigger the PlayStation Store purchase flow from within your game using the PlayStation commerce APIs.

{% hint style="warning" %}
For security reasons, we can con provide public documentation for PlayStation. [Please reach out to LootLocker via email if you are a registered PlayStation developer.](mailto:hello@lootlocker.com?subject=PlayStation%20Access)
{% endhint %}

### Validate Purchase with LootLocker

Send the PlayStation entitlement information to LootLocker for validation.

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

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

```csharp
LootLockerSDKManager.RedeemPlaystationStorePurchaseForPlayer(
    transaction_id: transactionIdFromPlayStation,
    auth_code: authCodeFromPlayStation,
    entitlement_label: "entitlement_label_configured_in_np_service",
    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.RedeemPlaystationStorePurchaseForClass(
    transaction_id: transactionIdFromPlayStation,
    auth_code: authCodeFromPlayStation,
    entitlement_label: "entitlement_label_configured_in_np_service",
    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 purchase flows
* Duplicate entitlement redemption
* Refund handling for consumed purchases
* Restoring or checking ownership for durable entitlements

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

### Conclusion

You now have the full PlayStation Store purchase flow implemented: initiating a purchase using PlayStation commerce APIs, validating the entitlement through LootLocker, and granting rewards to the player.

With this setup, you can securely support PlayStation 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/playstation-store/make-purchases-through-playstation.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.
