CheckoutComponents
Last updated: March 18, 2026
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 = {4// Handle payment success5},6),7addressConfiguration = AddressConfiguration(8// optional, prefilled address9data = ContactData(10address = Address(11addressLine1 = "123 Main St",12addressLine2 = "Sakura apartments",13city = "Tokyo",14state = "Shanghai",15country = Country.JAPAN,16zip = "100-0001",17),18phone = Phone(country = Country.UNITED_KINGDOM, number = "7425125181"),19name = Name(firstName = "John", lastName = "Doe"),20email = "johndoe@email.com"21),22// optional, what address fields to collect. Defaults to billing address23fields = listOf(24AddressField.Country,25AddressField.AddressLine1(),26AddressField.AddressLine2(),27AddressField.City(),28AddressField.State()29),30// optional, handle when contact data is saved31onComplete = { contactData -> handleContactData(contactData) }32),33// optional, enable Remember Me functionality34rememberMeConfiguration = RememberMeConfiguration(35data = RememberMeConfiguration.Data(36email = "jia.tsang@example.com",37phone = Phone(countryCode = "44", number = "7700900000")38),39showPayButton = true,40acceptedCardSchemes = listOf(CardSchemeName.Visa, CardSchemeName.AmericanExpress),41acceptedCardTypes = listOf(CardTypeName.Debit, CardTypeName.Credit, CardTypeName.Prepaid)42)43)444546try {47val flowComponent = checkoutComponents.create(ComponentName.Flow, options)4849val cardComponent = checkoutComponents.create(PaymentMethodName.Card, options)50} catch (checkoutError: CheckoutError) {51handleError(error = checkoutError)52}
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 = "johnDoe@domain.com",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()