CheckoutComponents
Last updated: October 6, 2025
Initializes a CheckoutComponentConfiguration instance.
1/**2* Common configurations for all payment components3*4* @property [Context] represents the application context5* @property [PaymentSessionResponse] paymentSession represents the payment session response6* @property publicKey represents the public API key, prefixed with pk_7* @property [Environment] represents the environment that the library points to, and sends requests to8* @property locale represents the customer’s locale and preferred language, used to localize the CheckoutComponents9* @property componentOptions [ComponentOptions] configures the component's behavior for different payment methods10* @property componentCallback [ComponentCallback] is a generic ComponentCallback for all payment methods11* @property translations contains translations for the component, including a map of Locale, with the value of another map of ComponentTranslationKey and the translation string12* @property flowCoordinators is a map containing all flow coordinators13* @property appearance contains the design tokens for customizing the component's appearance14*/15public data class CheckoutComponentConfiguration @JvmOverloads constructor(16val context: Context,17val paymentSession: PaymentSessionResponse,18val publicKey: String,19val environment: Environment,20val locale: Locale?,21val componentOptions: ComponentOptions,22val componentCallback: ComponentCallback?,23val translations: Translations?,24val flowCoordinators: Map<PaymentMethodName, FlowCoordinator>,25val appearance: DesignTokens? = null,26)
Initializes a CheckoutComponent instance.
1val configuration = CheckoutComponentConfiguration(2context = context,3paymentSession = PaymentSessionResponse(4paymentSessionId,5paymentSessionToken,6paymentSessionSecret,7),8publicKey = "YOUR_PUBLIC_KEY",9environment = Environment.SANDBOX,10)1112// Create CheckoutComponents13CoroutineScope(Dispatchers.IO).launch {14try {15val checkoutComponents = CheckoutComponentsFactory(config = configuration).create()16} catch (checkoutError: CheckoutError) {17handleError(checkoutError)18}19}
Initializes a PaymentMethodComponent instance.
1val options = ComponentOption(2callback = ComponentCallback(3onSuccess = { // Handle payment success }4),5// optional, enable collecting address for card payment6addressConfiguration = AddressConfiguration(7// optional, prefilled address8data = Contact(9address = Address(10addressLine1 = "123 Main St",11addressLine2 = "Sakura apartments",12city = "Tokyo",13state = "Shanghai",14country = Country.JAPAN,15zip = "100-0001",16)17),18// optional, what address fields to collect info. Default to billing address19fields = listOf(20AddressField.Country21AddressField.AddressLine1()22AddressField.AddressLine2()23AddressField.City()24AddressField.State()25),26// optional, handle when contact data is saved27onComplete = { contactData -> handleContactData(contactData) }28),29// optional, enable Remember Me functionality30rememberMeConfiguration = RememberMeConfiguration(31data = RememberMeConfiguration.Data(32email = "[email protected]",33phone = Phone(countryCode = "44", number = "7700900000")34),35showPayButton = true36)37)3839try {40val flowComponent = checkoutComponents.create(ComponentName.Flow, options)4142val cardComponent = checkoutComponents.create(PaymentMethodName.Card, options)43} catch (checkoutError: CheckoutError) {44handleError(error = checkoutError)45}
Initializes an address component instance.
1// Step 1: Create a configuration2val configuration = CheckoutComponentConfiguration(3context = context,4publicKey = "PUBLIC KEY",5environment = environment,6locale = Locale.EN,7)89// Step 2: Initialize an instance of Checkout Components SDK10val checkoutComponents = CheckoutComponentsFactory(config = configuration).create()1112// Step 3: Initialize an instance of prefilled address data (optional)13val prefilledData = ContactData(14address = Address(15country = Country.UNITED_KINGDOM,16addressLine1 = "Checkout.com",17),18phone = Phone(19countryCode = "+44",20number = "12345678",21),22name = Name(23firstName = "John",24lastName = "Doe",25),26email = "[email protected]",27)2829// Step 4: Create address with fields (optional)30val fields = listOf(31AddressField.Country,32AddressField.AddressLine1(),33AddressField.AddressLine2(isOptional = true),34AddressField.City(isOptional = false),35)3637// Step 5: Create an address configuration38val configuration = AddressConfiguration(39data = data,40fields = fields,41onComplete = { contactData ->42handleContactData(contactData)43}44)4546// Step 6: Create address component47val addressComponent = checkoutComponent.create(48ComponentName.Address(configuration)49)5051// Step 7: Render the address component52addressComponent.Render()