Skip to content

PaymentSheet

Renders a secure tokenization form as a modal sheet. When the buyer submits the form, the SDK tokenizes the payment details and returns a TokenizedResponse via the onPositiveClick callback.

Each form type comes in two style variants, Outlined and Classic, and shares the same parameters.

Function signature

CompletePaymentSheetOutlined(
    modifier, applicationId, isSandbox,
    paymentSheetResources, paymentSheetColors,
    logoTextStyle, textStyle, buttonTextFont,
    onDismiss, onNegativeClick, onPositiveClick
)
ParameterTypeRequiredDescription
applicationIdStringNoYour Finix Application ID. Defaults to sandbox environment.
isSandboxBooleanNotrue for sandbox, false for production. Defaults to true.
onDismiss() -> UnitYesCalled when the buyer dismisses the sheet without submitting.
onNegativeClick() -> UnitYesCalled when the buyer taps the cancel button.
onPositiveClick(TokenizedResponse) -> UnitYesCalled with the TokenizedResponse on successful submission.
paymentSheetResourcesPaymentSheetResourcesNoCustomize logo, button labels, and strings. See PaymentSheetResources.
paymentSheetColorsPaymentSheetColorsNoCustomize field, button, and error colors. See PaymentSheetColors.
modifierModifierNoJetpack Compose modifier applied to the sheet container.
logoTextStyleTextStyleNoText style for the logo label. Default: headlineSmall.
textStyleTextStyleNoText style for input fields. Default: LocalTextStyle.current.
buttonTextFontTextUnitNoFont size for button labels. Default: BUTTON_TEXT_FONT.

applicationId

Your Finix Application ID, found in the Finix Dashboard. Application IDs are environment-specific, so use the one that matches your chosen isSandbox value.

isSandbox

Controls which Finix environment the SDK connects to.

ValueEnvironment
trueSandbox
falseProduction

Your applicationId must belong to the same environment.

onDismiss / onNegativeClick / onPositiveClick

The three required callbacks control what happens when the buyer interacts with the sheet.

CallbackTriggerReceives
onDismissBuyer swipes the sheet awaynothing
onNegativeClickBuyer taps the cancel buttonnothing
onPositiveClickSuccessful tokenizationTokenizedResponse

Dismiss the sheet in all three callbacks to avoid leaving it open after interaction.

paymentSheetResources / paymentSheetColors

Pass PaymentSheetResources to customize text and images, and PaymentSheetColors to customize colors.

See PaymentSheetResources and PaymentSheetColors for all available properties.

Full example

A complete implementation with customized colors and resources, controlled by a ViewModel.

CompletePaymentSheetOutlined(
    applicationId = applicationId,
    isSandbox = isSandbox,
    paymentSheetResources = paymentSheetResources,
    paymentSheetColors = paymentSheetColors,
    onDismiss = onDismiss,
    onNegativeClick = onNegativeClick,
    onPositiveClick = onPositiveClick
)

// Sandbox
CompletePaymentSheetOutlined(
    applicationId = "APgPDQrLD52TYvqazjHJJchM",
    isSandbox = true,
    onDismiss = { },
    onNegativeClick = { },
    onPositiveClick = { token -> }
)

// Production
CompletePaymentSheetOutlined(
    applicationId = "APgPDQrLD52TYvqazjHJJchM",
    isSandbox = false,
    onDismiss = { },
    onNegativeClick = { },
    onPositiveClick = { token -> }
)

// Sandbox — use a sandbox Application ID
CompletePaymentSheetOutlined(
    applicationId = "APgPDQrLD52TYvqazjHJJchM",
    isSandbox = true,
    onDismiss = { },
    onNegativeClick = { },
    onPositiveClick = { token -> }
)

CompletePaymentSheetOutlined(
    applicationId = "APgPDQrLD52TYvqazjHJJchM",
    isSandbox = false,
    onDismiss = {
        // Sheet was closed without submitting
        viewModel.setShowPaymentSheet(false)
    },
    onNegativeClick = {
        // Buyer tapped cancel
        viewModel.setShowPaymentSheet(false)
    },
    onPositiveClick = { token ->
        // Tokenization succeeded — save the token and dismiss
        viewModel.saveTokenResponse(token)
        viewModel.setShowPaymentSheet(false)
    }
)

CompletePaymentSheetOutlined(
    applicationId = "APgPDQrLD52TYvqazjHJJchM",
    isSandbox = false,
    paymentSheetResources = PaymentSheetResources(
        logoText = R.string.my_brand_name,
        tokenizeButtonText = R.string.pay_now,
        cancelButtonText = R.string.back
    ),
    paymentSheetColors = PaymentSheetColors(
        tokenizeButtonColor = Color(0xFF00897B),
        tokenizeButtonTextColor = Color.White,
        focusedIndicatorColor = Color(0xFF00897B),
        focusedLabelColor = Color(0xFF00897B)
    ),
    onDismiss = { viewModel.setShowPaymentSheet(false) },
    onNegativeClick = { viewModel.setShowPaymentSheet(false) },
    onPositiveClick = { token ->
        viewModel.saveTokenResponse(token)
        viewModel.setShowPaymentSheet(false)
    }
)

@Composable
fun CheckoutScreen() {
    val viewModel = viewModel<CheckOutViewModel>()
    val state = viewModel.state

    if (state.showPaymentSheet) {
        CompletePaymentSheetOutlined(
            applicationId = "APgPDQrLD52TYvqazjHJJchM",
            isSandbox = false,
            paymentSheetResources = PaymentSheetResources(
                logoText = R.string.my_brand_name,
                tokenizeButtonText = R.string.pay_now
            ),
            paymentSheetColors = PaymentSheetColors(
                tokenizeButtonColor = Color(0xFF00897B)
            ),
            onDismiss = { viewModel.setShowPaymentSheet(false) },
            onNegativeClick = { viewModel.setShowPaymentSheet(false) },
            onPositiveClick = { token ->
                viewModel.saveTokenResponse(token)
                viewModel.setShowPaymentSheet(false)
            }
        )
    }
}