> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Implement the Callbacks

To Implement the WebGL SDK, include the following callback methods:

| Method                 | Description                                                                                                                    | Parameter     | Type |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------- | ---- |
| `OnInitialized`        | Triggered when checkout initialization is successful, after calling `CheckoutController.Instance.Init(...)`.                   |               |      |
| `OnInitializeFailed`   | Triggered when checkout initialization fails, after calling `CheckoutController.Instance.Init(...)`.                           |               |      |
| `OnPricePointsSuccess` | Triggered when price points are successfully retrieved, after calling `GetPricePoints`.                                        | `pricePoints` |      |
| `OnPricePointsFail`    | Triggered when price points can't be retrieved or are unavailable, after calling `GetPricePoints`.                             | `error`       |      |
| `OnPurchaseSuccess`    | Triggered when a purchase is successful.                                                                                       | `order`       |      |
| `OnPurchaseFailed`     | Triggered when the checkout window is closed or if an error occurs during the purchasing process, displaying an error message. | `error`       |      |

> **Note:** The interface includes three callback methods for purchase consumption, but their implementation is not relevant and therefore not applicable in this context.

## Example code

Below is the example code for the implementation:

<CodeGroup>
  ```kotlin C# theme={"system"}
  public class PurchaseHandler : ICheckoutPurchase
  {
      public void OnInitialized()
      {
          // Initialization was successful. You can now call GetPricePoints().
          Debug.Log("Initialization successful.");
      }
      
      public void OnInitializeFailed(ErrorMessage error)
      {
          Debug.Log(string.Format("Code: {0}\nMessage: {1}\nDetails: {2}", error.code, error.message, error.data));
      }
      
      public void OnPricePointsSuccess(PricePointsModel pricePoints)
      {
          // You can now display the localized pricing in the web store.
          Debug.Log(string.Format("Total Found: {0}", pricePoints.pricingPoints.Length));
      }

      public void OnPricePointsFail(ErrorMessage error)
      {
          Debug.Log(string.Format("Code: {0}\nMessage: {1}\nDetails: {2}", error.code, error.message, error.data));
      }
      
      public void OnPurchaseSuccess(OrderResponseModel order)
      {
          // Purchase was successful.
          Debug.Log(string.Format("Purchase Success:\nOrderId: {0}\nPayment Method: {1}", order.orderId, order.paymentMethodName));
      }
      
      public void OnPurchaseFailed(ErrorMessage error)
      {
          Debug.Log(string.Format("Code: {0}\nMessage: {1}\nDetails: {2}", error.code, error.message, error.data));
      }
  }
  ```
</CodeGroup>
