> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/analytics/api/events/inapppurchase.md).

# InAppPurchase

| Name             | Type                        | Select   | Backend name       | Description                                         |
| ---------------- | --------------------------- | -------- | ------------------ | --------------------------------------------------- |
| purchaseName     | string                      | Required | purchase\_name     | Name of the purchase/pack the user bought           |
| spentProducts    | Product                     | Required | spent\_products    | What products the user spent on                     |
| receivedProducts | Product                     | Required | received\_products | The user receives the product                       |
| productID        | string                      | Required | product\_id        | The Store SKU of the purchase unit                  |
| transactionID    | string                      | Required | transaction\_id    | The receipt ID provided by the Store                |
| placement        | string                      | Required | placement          | The location in the app where the purchase was made |
| receiptStatus    | ReceiptStatus               | Required | validated\_receipt | A receipt status object                             |
| isTestPurchase   | bool                        | Required | is\_test\_purchase | Whether the purchase was a test purchase            |
| additionalData   | Dictionary\<string, object> | Optional | additional\_data   | Any additional information                          |

## Override #1

The player purchased an IAP - Transaction Override

| Name           | Type                        | Select   | Backend name       | Description                                                   |
| -------------- | --------------------------- | -------- | ------------------ | ------------------------------------------------------------- |
| transaction    | Transaction                 | Required | transaction        | The Transaction object containing the data of the transaction |
| placement      | string                      | Required | placement          | The location in the app where the purchase was made           |
| receiptStatus  | ReceiptStatus               | Required | validated\_receipt | A receipt status object                                       |
| isTestPurchase | bool                        | Required | is\_test\_purchase | Whether the purchase was a test purchase                      |
| additionalData | Dictionary\<string, object> | Optional | additional\_data   | Any additional information                                    |

## Code examples:

```csharp
Product productSpent = new Product();
Product productReceived = new Product();
RealCurrency realCurrency = new RealCurrency("$", 25.99f);
productSpent.realCurrency = realCurrency;
int virtualMoneyAmount = Mathf.FloorToInt(1500f);
List<VirtualCurrency> virtualCurrencies = new List<VirtualCurrency>
{ new VirtualCurrency("Received a Pack of : ", "$", virtualMoneyAmount) };
productReceived.virtualCurrencies = virtualCurrencies;
Transaction transaction = new Transaction("store Transaction", "USD", productReceived, productSpent,
"xcf22f89574u45k6jy8", "com.studio.game.money1500");
transaction.AddSpentItem("free coins", "USD ", 0);
transaction.AddReceivedItem("free 5 coins", "coins", 5);
Dictionary<string, object> additionalData = new Dictionary<string, object>
{
    { "mission_data", new Dictionary<string, object>
        {
            { "mission_type", "main" },
            { "mission_name", "main_" },
            { "mission_id", 2 },
            { "mission_attempt", 10},
        }
    }
};
//Receipt status should be received either from adjust or lion's IAP package
LionAnalytics.InAppPurchase(
    transaction: transaction,
    placement: "store_money_tab",
    receiptStatus: ReceiptStatus.Success,
    isTestPurchase: true,
    additionalData: additionalData);
```

**Alternative method using Override #1 example:**

```csharp
Product productSpent = new Product();
Product productReceived = new Product();
RealCurrency realCurrency = new RealCurrency("$", 25.99f);
productSpent.realCurrency = realCurrency;
int virtualMoneyAmount = Mathf.FloorToInt(1500f);
List<VirtualCurrency> virtualCurrencies = new List<VirtualCurrency>
{ new VirtualCurrency("Received a Pack of : ", "$", virtualMoneyAmount) };
productReceived.virtualCurrencies = virtualCurrencies;
Dictionary<string, object> additionalData = new Dictionary<string, object>
{
    { "mission_data", new Dictionary<string, object>
        {
            { "mission_type", "main" },
            { "mission_name", "main_" },
            { "mission_id", 2 },
            { "mission_attempt", 10},
        }
    }
};
//Receipt status should be received either from adjust or lion's IAP package
LionAnalytics.InAppPurchase(
    purchaseName: virtualMoneyAmount + "Bought",
    spentProducts: productSpent,
    receivedProducts: productReceived,
    productID: "com.studio.game.money1500",
    transactionID: "xcf22f89574u45k6jy8",
    placement: "store_money_tab",
    receiptStatus: ReceiptStatus.Success,
    isTestPurchase: true,
    additionalData: additionalData);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lionstudios.gitbook.io/readme/analytics/api/events/inapppurchase.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
