CheckoutElementsController

Controls a Stripe Checkout Session: load it with configure, observe it through session, mutate it with the various update/apply/select methods, and present payment UI with a CheckoutElementsPresenter created via createPresenter.

Create instances with Builder.

Types

Link copied to clipboard
class Address(country: String)

Builder for an address passed to updateShippingAddress.

Link copied to clipboard
class Builder(application: Application, savedStateHandle: SavedStateHandle)

Builds CheckoutElementsController instances.

Link copied to clipboard
object Companion
Link copied to clipboard

Configuration options for a CheckoutElementsController, including per-element configuration and feature toggles. Build with the fluent setters and pass to CheckoutElementsController.configure.

Link copied to clipboard
sealed interface OperationResult

The result of a Checkout Controller operation such as configure or applyPromotionCode. Use Failed.displayMessage for customer-facing text. Failed.error retains diagnostic details.

Link copied to clipboard
sealed interface Result

The result of a checkout payment flow, delivered to ResultCallback.

Link copied to clipboard
fun interface ResultCallback

Callback invoked with the Result of a checkout payment flow, including failures before confirmation starts. Each rejected CheckoutElementsPresenter.confirm call delivers Result.Failed with an IllegalStateException explaining the reason. An active confirmation continues and delivers its own result.

Link copied to clipboard
class Session

A Session tracks the process of collecting a payment from your customer.

Properties

Link copied to clipboard
val isUpdating: StateFlow<Boolean>

Whether a mutation or confirmation is currently in progress or queued.

Link copied to clipboard

The latest Session data, or null when no checkout is configured. After successful confirmation, this is cleared after ResultCallback returns.

Functions

Link copied to clipboard

Clears the customer's selected payment option, resetting it to null.

Link copied to clipboard
suspend fun configure(clientSecret: String, configuration: CheckoutElementsController.Configuration = Configuration()): CheckoutElementsController.OperationResult

Loads the Checkout Session identified by clientSecret and prepares the payment UI, populating session on success.

Link copied to clipboard

Creates a CheckoutElementsPresenter bound to activity, used to present the payment UI for this checkout session.

Link copied to clipboard

Releases resources held by this controller and clears its loaded state. Call this when the controller is no longer needed.

Link copied to clipboard
suspend fun runServerUpdate(serverUpdate: suspend () -> Result<Unit>): CheckoutElementsController.OperationResult

Runs an async function that calls your server to update the Checkout Session, then automatically refreshes session with the latest session data.

Link copied to clipboard

Updates the customer's email address.

Link copied to clipboard

Sets the shipping address for this checkout.