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.

Return

Result: On Success CardToken, On ErrorResultError

Example:

val result = coreMethods.generateCardToken(
cardNumberState = cardNumberPCIState,
expirationDateState = expirationDatePCIState,
securityCodeState = securityCodePCIState,
buyerIdentification = BuyerIdentification(
name = "APRO",
number = "012345678909",
type = "CPF"
)
)

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

Parameters

cardNumberState

PCIFieldState containing the card number

expirationDateState

PCIFieldState containing the card expiration date

securityCodeState

PCIFieldStatecontaining the card security code

buyerIdentification

BuyerIdentification 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 uses the PCIFieldState for pass the values of the card in a secure way

Return

Result: On Success CardToken, On Error ResultError name, number and type

Example:

val result = coreMethods.generateCardToken(
cardId = "<cardID>",
expirationDateState = expirationDatePCIState,
securityCodeState = securityCodePCIState,
buyerIdentification = BuyerIdentification(
name = "APRO",
number = "012345678909",
type = "CPF"
)
)

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

Parameters

cardId

String The card id of a saved card

securityCodeState

PCIFieldStatecontaining the card security code

expirationDateState

PCIFieldState containing the card expiration date

buyerIdentification

BuyerIdentification information including name and document

See also