generateCardToken

suspend fun generateCardToken(cardNumberState: PCIFieldState, expirationDateState: PCIFieldState, securityCodeState: PCIFieldState, buyerIdentification: BuyerIdentification): Result<CardToken, ResultError>

Generates a secure card token from the provided card details. This method handles the tokenization of card information in a PCI-compliant manner, ensuring sensitive data is never exposed in the application. The method returns a Result type that can be either Success with a CardToken or Error with details.

Return

Result Success with token or Error with details

Example:

val result = coreMethods.generateCardToken(
cardNumberState = cardNumberField,
expirationDateState = expirationField,
securityCodeState = securityCodeField,
buyerIdentification = BuyerIdentification(
name = "John Doe",
number = "12345678",
type = "CPF"
)
)

when (result) {
is Result.Success -> {
val token = result.data.token
// Use token for payment processing
}
is Result.Error -> {
// Handle error
}
}

Parameters

cardNumberState

PCI-compliant state containing the card number

expirationDateState

PCI-compliant state containing the card expiration date

securityCodeState

PCI-compliant state containing the card security code

buyerIdentification

Buyer identification information including name and document

See also


suspend fun generateCardToken(cardId: String, securityCodeState: PCIFieldState, expirationDateState: PCIFieldState? = null, buyerIdentification: BuyerIdentification): Result<CardToken, ResultError>

Generate Card Token with a cardId call.

This return a Result.Success of CardToken data model or a Result.Error of ResultError This uses the PCIFieldState for pass the values of the card in a secure way This is a suspend function and should be called only from a coroutine or another suspend functionC

Parameters

cardId

String The card id of a saved card

securityCodeState

PCIFieldState of the security code text field

expirationDateState

PCIFieldState of the expiration date text field. This should only be provided if required.

buyerIdentification

BuyerIdentification data class that`s handle the buyer identification name, number and type

See also