struct CheckoutView: View { let clientToken: String @State private var showSuccess = false var body: some View { ZStack { PrimerCheckout( clientToken: clientToken, onCompletion: { state in if case .success = state { withAnimation { showSuccess = true } } } ) if showSuccess { SuccessOverlay() .transition(.opacity) } } }}
Listen for the primer:ready event to access the Primer SDK instance
Set the onPaymentSuccess callback
Access payment details and paymentMethodType from the callback parameters
Display your custom UI (modal, toast, inline message, etc.)
Use the onEvent callback on PrimerCheckoutSheet or PrimerCheckoutHost
Handle PrimerCheckoutEvent.Success to access PrimerCheckoutData with payment details
Navigate to a confirmation screen or update your order UI
Property
Type
Description
payment.id
String
The Primer payment ID
payment.orderId
String?
Your order ID
When using PrimerCheckoutSheet, the SDK shows a default success screen that auto-dismisses after 3 seconds. The Success event fires immediately — you do not need to wait for the dismiss. Navigate as soon as you receive the event.
Use the onCompletion callback on PrimerCheckout
Match on .success to detect payment completion
Access result.payment?.id for the payment ID
Update your SwiftUI state to show a custom success view
onDismiss fires after the sheet closes. If you already navigated away in onEvent, guard against double navigation.
Handle the .dismissed case to detect when the user closes the checkout:
PrimerCheckout( clientToken: clientToken, onCompletion: { state in switch state { case .success: withAnimation { showSuccess = true } case .dismissed: // User closed the checkout break default: break } })