> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/codapay/in-app-payments/unity-sdk-internal-beta-testing-unity-native-integration/unity-sdk-internal-beta-testing-introduction/integration-guide/initiate-payment.md).

# Initiate Payment

**Required Parameters**

| Parameter    | Type    | Description                          |
| ------------ | ------- | ------------------------------------ |
| orderId      | String  | Unique transaction ID (min. 4 chars) |
| price        | Integer | Amount in minor currency units       |
| countryCode  | Enum    | ISO 3166-1 alpha-2 code              |
| currencyCode | Enum    | ISO 4217 currency code               |
| userId       | String  | Unique user identifier               |

**Optional Parameters**:

| Parameter           | Type    | Description                                           |
| ------------------- | ------- | ----------------------------------------------------- |
| itemName            | String  | Name of the item being purchased                      |
| itemCode            | String  | Unique code for the item being purchased              |
| dynamic\_descriptor | String  | Appears on the user’s card/bank statement             |
| webhookUrl          | String  | URL for receiving payment status callbacks            |
| returnUrl           | String  | URL to redirect the user to after payment completion  |
| priceIncludesTax    | Boolean | Indicates if the price includes tax (default is true) |

Here's how you can initialize a payment, please see the example code:

```java
public class TestCodaSDKHandler : MonoBehaviour
{
     public Coda.CountryCode _countryCode = Coda.CountryCode.US; // Set this to Coda.CountryCode.ID to set default country as Indonesia for payment initiation.
     public Coda.CurrencyCode _currencyCode = Coda.CurrencyCode.USD; // // Set this to Coda.CountryCode.IDR to set default currency code as Indonesian Rupiah for payment initiation.
     
     public void OnPurchaseButtonClick()
     {
        Coda.PaymentSDK.InitiatePayment(
        orderId: "order1234",               // Required: Unique transaction ID
        price: 1000,                        // Required: In minor currency units
        countryCode: _countryCode,   // Required: ISO country code enum
        currencyCode: _currencyCode,// Required: ISO currency code enum
        userId: "user456",                  // Required: Unique user identifier
        // Optional
        itemName: "Special Sword",
        itemCode: "sword_001",
        dynamic_descriptor: "MYGAME",
        webhookUrl: "https://yourdomain.com/webhook",
        returnUrl: "https://yourgame.com/success");
    }
}
```

If you haven’t built the UI yet, create a basic Purchase/IAP screen.

Create and attach the script that initiates payment, to the empty GameObject or to the UI screen, base upon the architecture and structure of your game.\
Call `OnPurchaseButtonClick()` on the `OnClick` event of your Buy/Purchase/Upgrade button.

<figure><img src="https://611292228-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl56STCN5yoV1K1MhVEvU%2Fuploads%2FYys0WZM9jutxX3KpVQ4g%2FScreenshot%202568-06-19%20at%2016.09.22.png?alt=media&amp;token=756358c9-6c11-4674-9dea-ce415946f295" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Here, In the current setup `"TestCodaSDKHandler : Monobehaviour"`  script is attached to the empty GameObject named "TestCodaSDKHandler" in the SampleScene. You can setup this according to architecture of your game, just make sure to call  "`Coda.PaymentSDK.InitiatePayment`" function whenever you Initiate the payment process.
{% endhint %}

**Verification**:&#x20;

1. When you play with the help of <img src="https://611292228-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl56STCN5yoV1K1MhVEvU%2Fuploads%2FeNwbjJKb9buzHvXNzK6Q%2FScreenshot%202568-09-10%20at%2018.44.31.png?alt=media&amp;token=7872c9c7-552d-4618-bd6c-058aaa4ef2e0" alt="" data-size="line"> button on top toolbar and click "Purchase" button in the Game Window, you should be able to see the following screen if you set  `_countryCode = Coda.CountryCode.US & _currencyCode= Coda.CurrencyCode.USD`  in the example script shown above.

   <figure><img src="https://611292228-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl56STCN5yoV1K1MhVEvU%2Fuploads%2FWSkhQ8KAdZbM2UgyRLSO%2FScreenshot%202568-09-10%20at%2018.49.25.png?alt=media&amp;token=4785c4c6-966d-4ba3-843a-799a48498bb5" alt="" width="188"><figcaption></figcaption></figure>
2. When you play with the help of <img src="https://611292228-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl56STCN5yoV1K1MhVEvU%2Fuploads%2FeNwbjJKb9buzHvXNzK6Q%2FScreenshot%202568-09-10%20at%2018.44.31.png?alt=media&amp;token=7872c9c7-552d-4618-bd6c-058aaa4ef2e0" alt="" data-size="line"> button on top toolbar and click "Purchase" button in the Game Window, you should be able to see the following screen if you set `_countryCode = Coda.CountryCode.ID & _currencyCode= Coda.CurrencyCode.IDR`  in the example script shown above.                       &#x20;

   <figure><img src="https://611292228-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl56STCN5yoV1K1MhVEvU%2Fuploads%2FMXnO1g5qjFigbpNoQK4l%2FScreenshot%202568-09-10%20at%2018.57.18.png?alt=media&amp;token=f832a125-e905-47eb-be62-8f07c36f6c84" alt="" width="188"><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coda.co/codapay/in-app-payments/unity-sdk-internal-beta-testing-unity-native-integration/unity-sdk-internal-beta-testing-introduction/integration-guide/initiate-payment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
