CheckoutComponents
Last updated: December 3, 2025
Initializes a CheckoutComponentConfiguration instance.
1/**2Initializes a new instance of `Configuration`.3- Parameter paymentSession: Payment session details (optional for sessionless components)4- Parameter publicKey: Public key to submit payment session5- Parameter environment: Environment selection to interact with6- Parameter appearance: Design token for the user interface elements7- Parameter locale: Locale to be used by the SDK8- Parameter translations: Custom translation override strings9- Parameter callbacks: Callbacks to handle the component lifecycle10*/11public init(paymentSession: PaymentSession?,12publicKey: String,13environment: Environment,14appearance: DesignTokens = .init(),15locale: String? = nil,16translations: [String: [TranslationKey: String]] = [:],17callbacks: Callbacks) async throws(CheckoutComponents.Error)
Initializes a CheckoutComponent instance.
1// Initialize with a payment session2let configuration = try await CheckoutComponents.Configuration(3paymentSession: paymentSession,4publicKey: "YOUR_PUBLIC_KEY",5environment: .sandbox,6callbacks: initialiseCallbacks())78return CheckoutComponents(configuration: configuration)910// Or initialize for sessionless components (no payment session)11let sessionlessConfiguration = try await CheckoutComponents.Configuration(12paymentSession: nil,13publicKey: "YOUR_PUBLIC_KEY",14environment: .sandbox,15callbacks: initialiseCallbacks())1617return CheckoutComponents(configuration: sessionlessConfiguration)
1func initialiseCallbacks() -> CheckoutComponents.Callbacks {2.init(3onSuccess: { paymentMethod, paymentID in4// Handle payment success5},6onError: { paymentMethod in7// Handle payment error8}9)10}
Initializes an Actionable instance for payment flow.
1// Create a `flow component` with multiple options2try checkoutComponentsSDK.create(3.flow(options: [4.card(showPayButton: true, // show your own pay button when set to false5paymentButtonAction: .payment, // or `.tokenization`6displayCardHolderName: .top, // Position enum within the card view (.top, .bottom, .hidden)7addressConfiguration: addressConfiguration,8rememberMeConfiguration: rememberMeConfiguration),9.applePay(merchantIdentifier: "YOUR_MERCHANT_ID_HERE",10showPayButton: Bool = true) // show your own pay button when set to false11])12)1314// Create a specific payment method15try checkoutComponentsSDK.create(16.card(showPayButton: true,17paymentButtonAction: .payment,18displayCardHolderName: .top, // Position enum within the card view (.top, .bottom, .hidden)19addressConfiguration: addressConfiguration,20rememberMeConfiguration: rememberMeConfiguration)21)
Tip
If you use Apple Pay as a standalone component with your custom payment button, ensure you follow Apple's guidelines for showing Apple Pay logo.
Initialize a sessionless component that doesn't require a payment session.
1// Create a sessionless address component2typealias ContactData = CheckoutComponents.ContactData3typealias Address = CheckoutComponents.Address4typealias Configuration = CheckoutComponents.AddressConfiguration56let prefilledAddress = ContactData(address: .init(country: .unitedKingdom,7addressLine1: "Wenlock Works",8addressLine2: "Shepherdess Walk",9city: "London",10zip: "N1 7BQ"),11phone: .init(countryCode: "+$4",12number: "1234567890"),13name: .init(firstName: "John",14lastName: "Doe"))1516let addressConfiguration = Configuration.init(data: prefilledAddress,17fields: CheckoutComponents.AddressField.billing18+ [.phone(isOptional: false)]) { collectedAddress in19debugPrint("Collected address: \(collectedAddress)")20}2122try checkoutComponentsSDK.create(23.address(configuration: addressConfiguration)24)
Updates a FlowComponent instance.
1if component.isAvailable {2component.render()3}
This method only updates the UI. To update the payment session, use the handleSubmit callback.
The update() method takes the updateDetails object as a parameter, which contains the values to update.
This object uses the amount property to update the purchase amount. This value must be:
- Greater than zero
- Expressed in the minor currency unit
1let callbacks = CheckoutComponents.Callbacks(handleSubmit: { sessionData in2submitPaymentSession(sessionData)3})4let configuration = CheckoutComponents.Configuration(..., callbacks: callbacks)56try checkoutComponentsSDK.update(with: UpdateDetails(amount: 100))