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

Register Callback Events

After adding the Coda SDK Prefab to your scene, you need to register to the callback events.

Event Listeners

Event Name

Description

OnPurchaseSuccess

Triggered when a payment completes successfully.

OnPurchaseFailed

Triggered when a payment fails, with error details.

OnPriceChanged

Triggered when price updates (e.g., tax adjustments).

Two ways to register listeners:

  • Inspector Method

  1. Create and attach your handler script to an empty GameObject, then link its methods to the events of PaymentSDK Script attached to the Coda prefab(Added to Hierarchy in the previous step) using the Inspector Tab. You can create the handler script similar to the following example script:

public class TestCodaSDKCallbacksHandler : MonoBehaviour
{
    public void OnPurchaseSuccess(string orderId) {
        Debug.Log("Success: " + orderId);
    }
    public void OnPurchaseFailed(string orderId, string error) {
        Debug.Log("Failed: " + error);
    }
    public void OnPriceChanged(double updatedPrice) {
        Debug.Log("Price Updated: " + updatedPrice);
    }
}

You can checkout a step-by-step video walkthrough how to register event listeners through Inspect window here.

  1. 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:

  • Programmatic Method — Create and attach your handler script to an empty GameObject, implement Coda.IPaymentEventListener, and register the event listeners inside your handler script as shown in the following Example:

If you are not aware of how you can "Create and attach your handler script to an empty GameObject", checkout a step-by-step video walkthrough how to register event listeners programmatically here.

Last updated

Was this helpful?