> 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="/files/qLIZFEpCq33LEKUr2hp4" 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="/files/Hapa9E065q4nuTXqGwto" 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="/files/nTqT7NOfzLR6myq1mFI8" alt="" width="188"><figcaption></figcaption></figure>
2. When you play with the help of <img src="/files/Hapa9E065q4nuTXqGwto" 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="/files/qUAB9NjIQo5EJlhwvgSq" 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 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://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=<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.
