CheckoutComponents
Last updated: December 2, 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 baseUrlPrefix represents your account's unique base URL prefix for routing requests to your regional host. Required. Use the same {prefix} as in the Create a Payment Session base URL9* @property locale represents the customer’s locale and preferred language, used to localize the CheckoutComponents10* @property componentOptions [ComponentOptions] configures the component's behavior for different payment methods11* @property componentCallback [ComponentCallback] is a generic ComponentCallback for all payment methods12* @property translations contains translations for the component, including a map of Locale, with the value of another map of ComponentTranslationKey and the translation string13* @property flowCoordinators is a map containing all flow coordinators14* @property appearance contains the design tokens for customizing the component's appearance15*/16public data class CheckoutComponentConfiguration @JvmOverloads constructor(17val context: Context,18val paymentSession: PaymentSessionResponse,19val publicKey: String,20val environment: Environment,21val baseUrlPrefix: String,22val locale: Locale?,23val componentOptions: ComponentOptions,24val componentCallback: ComponentCallback?,25val translations: Translations?,26val flowCoordinators: Map<PaymentMethodName, FlowCoordinator>,27val appearance: DesignTokens? = null,28)
Initializes a CheckoutComponent instance.
1val configuration = CheckoutComponentConfiguration(2context = context,3paymentSession = PaymentSessionResponse(4paymentSessionId,5paymentSessionToken,6paymentSessionSecret,7),8publicKey = "YOUR_PUBLIC_KEY",9environment = Environment.SANDBOX,10baseUrlPrefix = "{prefix}", // Required. The same {prefix} as your Create a Payment Session base URL.11)1213// Create CheckoutComponents14CoroutineScope(Dispatchers.IO).launch {15try {16val checkoutComponents = CheckoutComponentsFactory(config = configuration).create()17} catch (checkoutError: CheckoutError) {18handleError(checkoutError)19}20}
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,6baseUrlPrefix = "{prefix}",7locale = Locale.EN,8)910// Step 2: Initialize an instance of Checkout Components SDK11val checkoutComponents = CheckoutComponentsFactory(config = configuration).create()1213// Step 3: Initialize an instance of prefilled address data (optional)14val prefilledData = ContactData(15address = Address(16country = Country.UNITED_KINGDOM,17addressLine1 = "Checkout.com",18),19phone = Phone(20countryCode = "+44",21number = "12345678",22),23name = Name(24firstName = "John",25lastName = "Doe",26),27email = "johnDoe@domain.com",28)2930// Step 4: Create address with fields (optional)31val fields = listOf(32AddressField.Country,33AddressField.AddressLine1(),34AddressField.AddressLine2(isOptional = true),35AddressField.City(isOptional = false),36)3738// Step 5: Create an address configuration39val configuration = AddressConfiguration(40data = data,41fields = fields,42onComplete = { contactData ->43handleContactData(contactData)44}45)4647// Step 6: Create address component48val addressComponent = checkoutComponent.create(49ComponentName.Address(configuration)50)5152// Step 7: Render the address component53addressComponent.Render()
Initializes a sessionless CVV component to collect a security code for a card you hold yourself, with no payment session. The component tokenizes on demand and returns the token to you, rather than submitting anything to Checkout.com.
Unlike other components, card-cvv is not pulled in by the main checkout-android-components artifact, so you must add the dependency explicitly:
1dependencies {2implementation("com.checkout:checkout-android-components:$latest_version")3implementation("com.checkout:checkout-android-components-card-cvv:$latest_version")4}
No payment session is needed, so use the CheckoutComponentConfiguration overload that takes no paymentSession:
1val configuration = CheckoutComponentConfiguration(2context = this,3publicKey = "pk_sbox_...",4environment = Environment.SANDBOX,5baseUrlPrefix = "{prefix}",6)78val checkoutComponents = CheckoutComponentsFactory(config = configuration).create()910val cvvComponent = checkoutComponents.create(11ComponentName.CardCvv(12configuration = CardCvvConfiguration(13cardCvvLength = setOf(3, 4),14callback = CardCvvComponentCallback(15onReady = { component ->16/* component is ready */17},18onChange = { component ->19/* re-read component.isValid() */20},21),22),23),24)2526// Render in Compose UI with cvvComponent.Render(), or in a View container27// with cvvComponent.provideView(container).2829// Tokenize when the customer is ready.30when (val result = cvvComponent.tokenize()) {31is CardCvvTokenizeResult.Success ->32// Send result.token to your backend as the CVV for your own payment request.33Log.d("cvv", result.token)34is CardCvvTokenizeResult.Failure ->35Log.e("cvv", result.error.code.toString())36}
cardCvvLength accepts any combination of 3 and 4. Unsupported values are dropped, so setOf(3, 5) validates against setOf(3). When null, empty, or holding no supported length, both 3 and 4 are accepted, so the SDK never produces a field that cannot be satisfied.