For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integration Guide

Integrate with the SDK

Once the SDK is configured, you can embed it into your game by following steps:

  • Add Coda SDK Prefab

  • Handle the payment result

Step 1: Add Coda SDK Prefab

Adding the Coda SDK Prefab into your game allows the SDK to initialize at runtime. One way to do this is by adding the Prefab to a scene.

Once the required scene is open, you can view objects in the hierarchy panel and add the Coda SDK Prefab using either of the following methods:

  • Using the Coda menu: Coda → Create Prefab

  • Drag from the Project panel into the Hierarchy panel: Navigate to Assets > Plugins > Coda > Prefabs

Step 2: Handle the Payment Result

After adding the Coda SDK Prefab to your scene, you need to handle payment result events. There are two ways to register event listeners to the Coda SDK:

  • Through the Inspector window

  • Programmatically

Register your event listeners through the Inspector Window

To register event listeners via the Inspector window:

  1. Create a script to handle callbacks from the event listeners. For example:

  1. Create an Empty GameObject in the scene: Right-click in the “Hierarchy” window → Select Create Empty. Rename the object and attach your script to it.

  1. Select the Coda SDK Prefab in your scene (Hierarchy panel). In the Inspector panel, you will see the On Payment Success, On Payment Failure, and On Price Update events under the PaymentSDK script. This is where you register your GameObject methods as callbacks.

  1. Click the “+” button under the On Payment Success event to add a callback slot.

  1. Drag your GameObject from the Hierarchy panel into the callback slot.

  1. Select the method to be called when payment is successful.

Register event listeners for failure and price update events in the same way. Once registered, your Inspector window for the Coda prefab should look like this:

Register your event listeners programmatically

You can also register event listeners programmatically:

  1. Implement the Coda.IPaymentEventListener interface in your script.

  2. Register event listeners when your script is loaded:

  1. Unregister event listeners when your script is unloaded:

Example implementation:

You can check full list of available event listeners here.

Initiate a Payment

Once everything is set up, you can initiate a payment flow. A payment flow can be triggered from anywhere in your game—typically when a user taps a Buy, Purchase, or Upgrade button.

To start the payment flow, call Coda.PaymentSDK.InitiatePayment()

You can use the same script that handles callbacks or create a new one (e.g., TestCodaSDKHandler) with the InitiatePayment function, then attach it to an Empty GameObject in the scene (see step 2).

This launches the payment UI, allowing users to complete their purchase through Codapay’s network.

Example code:

You can check full list of parameters here.

If you haven’t built the UI yet, create a basic Purchase/IAP screen. Call OnPurchaseButtonClick() on the OnClick event of your Buy/Purchase/Upgrade button.

Last updated

Was this helpful?