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

# Payment outcomes

> Success and failure outcomes, delivered as terminal states of PrimerCheckoutState

> [!WARNING]
>
> Primer Checkout Android SDK is currently in **beta** (v3.0.0-beta.8).
> The API is subject to change before the stable release.

Payment outcomes are terminal states of [`PrimerCheckoutState`](https://primer.io/docs/sdk/android-checkout/v3.0.0-beta/api/primer-checkout-state), observed via `PrimerCheckoutController.state`. There is no separate event callback.

> [!NOTE]
>
> Earlier previews delivered outcomes through a `PrimerCheckoutEvent` type and an `onEvent` lambda on `PrimerCheckoutSheet` / `PrimerCheckoutHost`. Both were removed — `Success` and `Failure` are now cases of `PrimerCheckoutState`.

## Outcomes

```kotlin theme={"dark"}
sealed interface PrimerCheckoutState {
    // ...
    data class Success(val checkoutData: PrimerCheckoutData) : PrimerCheckoutState
    data class Failure(
        val primerError: PrimerError,
        val checkoutData: PrimerCheckoutData? = null,
    ) : PrimerCheckoutState
}
```

### Success

Reached when payment completes successfully. Only emitted in `AUTO` payment handling mode.

| Property | Type | Description |
| - | - | - |
| `checkoutData` | `PrimerCheckoutData` | Payment result containing payment ID and order ID |

### Failure

Reached when a payment fails or an error occurs.

| Property | Type | Description |
| - | - | - |
| `error` | [`PrimerError`](https://primer.io/docs/sdk/android-checkout/v3.0.0-beta/api/common/primer-error) | Error details including description, error code, and diagnostics ID |

## Reacting to outcomes

```kotlin theme={"dark"}
val checkout = rememberPrimerCheckoutController(clientToken, settings)
val state by checkout.state.collectAsStateWithLifecycle()

LaunchedEffect(state) {
    when (val s = state) {
        is PrimerCheckoutState.Success -> navigateToConfirmation(s.checkoutData)
        is PrimerCheckoutState.Failure -> logError(s.primerError)
        else -> Unit
    }
}

PrimerCheckoutSheet(checkout = checkout)
```

The built-in `success` / `error` slots on [`PrimerCheckoutSheet`](https://primer.io/docs/sdk/android-checkout/v3.0.0-beta/api/primer-checkout-sheet) render the in-sheet result screens; observe `state` when you need to react programmatically (navigate, log, clear the cart).

## PrimerCheckoutData

```kotlin theme={"dark"}
data class PrimerCheckoutData(
    val payment: Payment,
)
```

### Payment

```kotlin theme={"dark"}
data class Payment(
    val id: String,
    val orderId: String,
)
```

| Property | Type | Description |
| - | - | - |
| `id` | `String` | Unique payment identifier assigned by Primer |
| `orderId` | `String` | Order identifier from the client session |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.