> ## 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

## Callback methods

To implement the Android Payment Links SDK, include the following callback methods:

| Method | Description | Argument | Type |
| - | - | - | - |
| `onInitialized` | Triggered when SDK initialization was successful. | | |
| `onInitializeFailed` | Triggered when SDK initialization failed. | `error` | `SdkError` |
| `onPurchaseSuccess` | Triggered when a purchase was successful. | `order` | `OrderResponseModel` |
| `onPurchaseFailed` | Triggered when a server-to-server error or any other purchase error occurs. Returns a unique integer error code, a detailed message, a raw JSON string if available, and order details. | `error`, `order` | `SdkError`, `OrderResponseModel?` |
| `onPurchaseCanceled` | Triggered when the checkout window is dismissed or the purchase is canceled. Returns a unique integer error code, a detailed message, a raw JSON string if available, and order details. | `error`, `order` | `SdkError`, `OrderResponseModel?` |

### OrderResponseModel properties

The `OrderResponseModel` argument type contains the following properties:

| Property Name | Type | Description | Example |
| - | - | - | - |
| `date` | `Int` | Unix timestamp of the order. | `1718182312` |
| `sessionToken` | `String` | Unique token for the current session. | `"xxxxXXXXxxxxXXXXxxxx"` |
| `offerName` | `String` | Name of the purchased offer. | `"Starter Pack"` |
| `offerSku` | `String` | SKU identifier for the offer. | `"starter_pack_001"` |
| `items` | `[Item]` | List of items included in the purchase. | `[{ name: "Gems", sku: "gem_01", quantity: "100" }]` |
| `items.name` | `String` | Display name of the item. | `"Gems"` |
| `items.sku` | `String` | Unique SKU code for the item. | `"gem_01"` |
| `items.quantity` | `String` | Quantity of the item included. | `"100"` |
| `price` | `Int` | Price of the order in minor units. For example, cents for USD. | `499` |
| `currency` | `String` | ISO 4217 currency code | `"USD"` |
| `customerId` | `String` | ID of the player who made the purchase. | `"cust_98765"` |
| `customerCountry` | `String` | Country code of the player in ISO 3166-1 alpha-2 format. | `"US"` |
| `paymentMethodName` | `String` | Payment method. | `"Visa"` |
| `orderId` | `String` | Order ID. | `"1234567890"` |
| `purchaseId` | `String` | A unique ID to track the transaction. | `"pr_xxxxxx"` |

### SdkError properties

The `SdkError` argument type contains the following properties:

| Property Name | Type | Description | Example |
| - | - | - | - |
| `code` | `Int` | Error code identifying the failure. | `3002` |
| `message` | `String` | Detailed message describing the failure. | `"Purchase canceled because the user closed the checkout interface."` |

## Example code

```kotlin Kotlin theme={"system"}
BridgeAPI.init(context, configModel, object : ICheckoutPurchase {

    override fun onInitialized() {
    // Handle initialization success
    }

    override fun onInitializeFailed(error: SdkError) {
        // Handle initialization fail
    }

    override fun onPurchaseSuccess(order: OrderResponseModel) {
        // Handle purchase success
    }

    override fun onPurchaseFailed(error: SdkError, order: OrderResponseModel? = null) {
        // Handle purchase failure
    }

    override fun onPurchaseCanceled(error: SdkError, order: OrderResponseModel? = null) {
        // Handle purchase canceled
    }
})
```
