CoreMethods

CoreMethods is the main class responsible for handling all core payment-related operations in the MercadoPago SDK. It provides methods for card tokenization, installment calculations, and payment method management. This class ensures secure handling of sensitive card data through PCI-compliant field states.

Example:

// Get CoreMethods instance
val coreMethods = MercadoPagoSDK.getInstance().coreMethods

// Generate card token
val result = coreMethods.generateCardToken(
cardNumberState = cardNumberPCIState,
expirationDateState = expirationPCIState,
securityCodeState = securityCodePCIState,
buyerIdentification = buyerHolder
)

See also

Types

Link copied to clipboard
object Companion

Companion object for the CoreMethods class.

Functions

Link copied to clipboard
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.

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

Generate Card Token with a cardId call.

Link copied to clipboard
suspend fun getCardIssuers(bin: String, paymentMethodId: String): Result<List<CardIssuer>, ResultError>

Retrieves the list of available card issuers for a given card BIN and payment method. This method helps identify which banks or financial institutions can process the card based on its first digits and the selected payment method. The result includes issuer details such as ID, name, and processing capabilities.

Link copied to clipboard

Retrieves the list of available identification types for the current country. This method helps identify which types of identification documents (CPF, CNPJ, DNI, etc.) are accepted for payment processing in the current market. The result includes validation rules for each identification type.

Link copied to clipboard
suspend fun getInstallments(bin: String, amount: BigDecimal, processingMode: ProcessingMode = ProcessingMode.Aggregator): Result<List<Installment>, ResultError>

Retrieves available installment options for a given card and amount. This method calculates all possible installment plans based on the card's BIN, transaction amount, and processing mode. The result includes detailed information about each installment option including rates and fees.

Link copied to clipboard

Retrieves the list of available payment methods for a given card BIN. This method helps identify which payment methods (credit card, debit card, etc.) can be used based on the card's first digits. The result includes detailed information about each payment method including fees, processing times, and required fields.