AsyncStream for continuous observation and onCompletion for the final payment result.
Checkout state lifecycle
PrimerCheckoutState
The top-level checkout state, observed viaPrimerCheckoutScope.state:
| State | Description |
|---|---|
.initializing | SDK is loading configuration and payment methods |
.ready(totalAmount:currencyCode:) | Checkout is ready for user interaction |
.success(PaymentResult) | Payment completed successfully |
.failure(PrimerError) | Payment failed |
.dismissed | Checkout was dismissed |
Observing checkout state
onCompletion callback
TheonCompletion callback fires when the checkout reaches a terminal state (success, failure, or dismissed):
onCompletion receives the same PrimerCheckoutState enum as the AsyncStream. Use onCompletion when you only need to react to the final result, and AsyncStream when you need to track intermediate states.Payment method scope states
Each payment method scope has its own state type:PrimerCardFormState
| Property | Type | Description |
|---|---|---|
isValid | Bool | Whether all required fields pass validation |
isLoading | Bool | Whether the form is submitting |
fieldErrors | [FieldError] | Current validation errors |
selectedNetwork | PrimerCardNetwork? | Detected card network |
availableNetworks | [PrimerCardNetwork] | Available card networks for co-badged cards |
displayFields | [PrimerInputElementType] | Fields to display based on configuration |
selectedCountry | PrimerCountry? | Selected country for billing address |
See also
Scopes overview
All available scopes and their relationships
Handle payment result
Navigate after payment completion
Error handling
Handle validation and payment errors