Payment
Payment, part of Mercado Pago SDK Checkout, provides a payment method selector and processes orders in native Android and iOS applications. Buyers can use a saved card, enter a new card or generate Rapipago and Pago Fácil instructions, according to the order rules.
Your backend creates the order and confirms the financial status of the purchase. The SDK manages the selected method steps, including CVV, card form, installments, review and results when applicable. The card token used for processing remains inside the SDK.
Prepare the integration
Configure SDK Checkout in the development environment. Use a supported release and keep Checkout and Core Methods on the same version. Obtain application test credentials in Your integrations.
- Android: enable Compose. Use the SDK BoM to align modules. The SDK requires Android 6.0 or later (
minSdk 23) and Kotlin 2.0 or later. - iOS: add the
MercadoPagoCheckoutproduct through Swift Package Manager. The package declares iOS 13 as its minimum platform and Swift tools 6.0; use an Xcode version compatible with your chosen release.
Initialize the application with the Public KeyPublic credential that identifies the application in the SDK.. Keep the Access TokenPrivate credential used by your backend. Never include it in the mobile application. only in your backend. Use credentials from the same application and environment.
The examples were checked against Android 1.0.4 and iOS 1.3.0, which include Payment, review and Status Screen. These are verified versions for this guide; they do not establish the first release to include each feature.
Initialize the SDK
Initialize once at application startup, before opening checkout. Do not repeat initialization for every payment attempt.
import android.app.Application
import com.mercadopago.sdk.android.domain.model.CountryCode
import com.mercadopago.sdk.android.initializer.MercadoPagoSDK
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
MercadoPagoSDK.initialize(
context = this,
publicKey = "YOUR_TEST_PUBLIC_KEY",
countryCode = CountryCode.ARG,
)
}
}
Register MyApplication as your manifest Application class.
Create the order in your backend
Create an online order through /v1/ordersPOST in manual mode (processing_mode: "manual"). Do not send a card or token transaction at this point: the SDK collects the selected method and completes processing. The amount, payer and payment rules belong to the order.
curl --request POST 'https://api.mercadopago.com/v1/orders' \
--header "Authorization: Bearer $MP_ACCESS_TOKEN" \
--header "X-Idempotency-Key: $MP_IDEMPOTENCY_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "online",
"processing_mode": "manual",
"total_amount": "100.00",
"external_reference": "purchase-1234",
"payer": { "email": "test_payer@example.com" },
"items": [
{ "title": "Product", "quantity": 1, "unit_price": "100.00" }
]
}'
Define MP_ACCESS_TOKEN only in your backend. Generate MP_IDEMPOTENCY_KEY for the logical order creation. Replace illustrative data with your purchase and test-payer data; add the fields required by the Orders contract for your scenario. The response provides id and client_token: send them to the application as the orderId and clientToken of MPOrder. Do not log clientToken.
Integrate by platform
Use the order received from your backend. openPaymentCheckout is an application-defined helper in this example, not an SDK method. show opens the SDK Activity and can be triggered from Compose or Views; it does not return a View to embed in Compose.
import android.app.Activity
import com.mercadopago.sdk.android.checkout.core.MercadoPagoCheckout
import com.mercadopago.sdk.android.checkout.core.model.*
import com.mercadopago.sdk.android.checkout.domain.callback.MercadoPagoCheckoutResult
fun openPaymentCheckout(activity: Activity, order: MPOrder) {
val checkout = MercadoPagoCheckout.Builder(
context = activity,
checkoutType = MPCheckoutType.Payment(
order = order,
sellerInfo = MPSellerInfo(
name = "My Store",
logoUrl = "https://example.com/logo.png",
),
),
).build()
checkout.show { result ->
when (result) {
is MercadoPagoCheckoutResult.Success -> {
val payment = result.paymentData
// Reconcile payment.orderId in your backend.
}
is MercadoPagoCheckoutResult.Error -> {
// Handle the failure in your application.
}
is MercadoPagoCheckoutResult.UserCancelled -> {
val screens = result.cancelledData.screens
// Return to the cart.
}
}
}
}
| Field | Type | Description | Example | Required |
context | Context | Context of the Activity that opens checkout. | activity | Yes |
checkoutType | MPCheckoutType.Payment | Selects the Payment flow. | Payment | Yes |
order | MPOrder | ID and token of the order created in the backend. | orderId, clientToken | Yes |
sellerInfo | MPSellerInfo? | Name and logo displayed in review and results. | name, logoUrl | No |
checkoutAppearance | MPCheckoutAppearance? | Checkout appearance. | MPCheckoutAppearance() | No |
The backend retrieves saved cards using payer.customer_id; without this identifier, it may also locate the customer by email. CVV and installments are displayed according to returned data; inapplicable steps are skipped. Credit, debit and prepaid availability depends on order rules. A new card is not automatically saved for future purchases.
The success result is MPPaymentData.Payment. It does not contain transactionAmount, a card token, payment code, receipt URL or expiration date. Query the order in your backend to obtain these details outside the Status Screen.
| Field | Type | Description | Example | Required |
orderId | String | Processed order ID. | ORDER_ID | Yes |
orderStatus | String | Status after processing; it does not establish approval on its own. | action_required | Yes |
paymentMethodId | String | Payment method used. | visa, rapipago | Yes |
paymentTypeId | String | Payment method type. | credit_card, debit_card, prepaid_card, ticket | Yes |
orderStatusDetail | String? | Optional status detail. | waiting_payment | No |
A success callback does not by itself confirm payment approval. After Rapipago or Pago Fácil instructions are generated, the order may remain in action_required / waiting_payment: the buyer still needs to pay. A card may also return a pending result under review or processing. Confirm the financial status in your backend before fulfilling the purchase.
Error reports a flow failure. UserCancelled returns MPUserCancelledContext.Payment with the screens history. Status Screen closure is reported by onExit, separately from the processing result.
Review is optional and disabled by default. Enable withReviewAndConfirm before build. The screen displays the backend summary and processes the order after buyer confirmation. The buyer can change the payment method before confirming. Returning to the preceding step does not by itself cancel the entire checkout.
Change the email for offline payments
For offline payments, review may show a masked email. Provide onEmailChangeRequested to enable changes. The SDK closes checkout and invokes this callback without reporting cancellation. Your application collects the new email, creates another order in the backend and builds a new checkout instance. The SDK does not modify the order email in memory. Without this callback, the email is read-only.
import com.mercadopago.sdk.android.checkout.core.extensions.withReviewAndConfirm
val checkout = MercadoPagoCheckout.Builder(
context = activity,
checkoutType = MPCheckoutType.Payment(order = order),
)
.withReviewAndConfirm()
.build()
val checkoutWithEmailChange = MercadoPagoCheckout.Builder(
context = activity,
checkoutType = MPCheckoutType.Payment(order = order),
)
.withReviewAndConfirm(onEmailChangeRequested = {
// Collect the email, create another order and reopen checkout.
})
.build()
In the additional snippets, activity and order are values from your application.
Handle loading failures
If review fails to load, the buyer may return to the preceding step with feedback, without checkout ending through the error callback. Do not interpret this navigation as payment confirmation.
Status Screen is optional and disabled by default. Enable withStatusScreen, with the required onExit callback, to display results within checkout. It works with or without review; to omit review from the example, remove only withReviewAndConfirm.
import com.mercadopago.sdk.android.checkout.core.extensions.withReviewAndConfirm
import com.mercadopago.sdk.android.checkout.core.extensions.withStatusScreen
val checkout = MercadoPagoCheckout.Builder(
context = activity,
checkoutType = MPCheckoutType.Payment(
order = order,
sellerInfo = MPSellerInfo(name = "My Store"),
),
)
.withReviewAndConfirm()
.withStatusScreen(onExit = {
// Resume your application and reconcile the order in your backend.
})
.build()
checkout.show { result ->
when (result) {
is MercadoPagoCheckoutResult.Success -> {
val payment = result.paymentData
// Preserve payment; keep checkout open for the status screen.
}
is MercadoPagoCheckoutResult.Error -> {
// Handle the failure; do not close the status screen here.
}
is MercadoPagoCheckoutResult.UserCancelled -> {
val screens = result.cancelledData.screens
// Return to the cart.
}
}
}
The processing result may arrive before Status Screen is displayed. Keep checkout open when success or error arrives if that screen still needs to appear. onExit reports closure and carries neither order data nor approval. There is no Exit result. Initialization errors, validation errors and cancellations may end the flow before this screen; do not rely exclusively on onExit to reconcile every attempt.
| Presentation | Content and expected action |
| Approved | Approval feedback, store details, summary and receipt when returned. The approval presentation differs from the success callback. |
| Pending | Manual review, contingency or processing. It may show guidance and a back action; a barcode is not required and retry is not offered. |
| Offline instructions | Payment code, copy action, expiration and document when available. Generating instructions does not establish approval. |
| Rejection or failure | Error title, payment method summary, operation number and guidance when available. It may offer changing the payment method when the order permits retry; a store row is not guaranteed. |
If the Status Screen query fails, the SDK may display fallback content from processing data, or a generic error if data is missing. This presentation does not guarantee all details and actions from the original response. Preserve the result and query the order in your backend.
Receipt and privacy
When available, the receipt is downloaded and shared through Android native sharing. The SDK already declares the FileProvider with authority ${applicationId}.mercadopago.checkout.fileprovider; do not declare another with the same authority. Downloads accept PDFs up to 5 MiB, without following redirects. If download or sharing fails, the SDK attempts to open the original URL in an external application; this path is not subject to the local download 5 MiB limit.
Receipts are cached. Files older than 24 hours are removed when cleanup runs again upon entering Status Screen or starting another download; deletion is not scheduled for exactly 24 hours. Screenshot blocking applies to the loaded screen, without a guarantee for every fallback state. Remote URLs undergo HTTPS filtering and blocking of known literal local or private hosts; this is not DNS validation of a public destination. Barcode images may also use data:image/png;base64. Displayed card data is limited to the last four digits.
To check eligibility, query the order in your backend: the documented combination is status: action_required and status_detail: waiting_retry. waiting_retry is not a status value. Authorize attempts with config.online.retries.allowed: true. Changing the method on Status Screen depends on the server returning the change_payment_method action; the flag and order state alone do not guarantee that the button appears. can_retry belongs to the Status Screen response, not the order creation body. When the action is offered, the buyer returns to the selector for another attempt with the same order. Reconcile all results by orderId. The pending presentation does not offer retry.
Configure backend authorization as described in Behavior and support. To reopen the experience from your application, build another instance with Builder and reconcile the order before deciding whether to create a new purchase.
Confirm payment in your backend
Query the order in your backend and configure notifications to track later changes. If the response or connection is lost, reconcile the same order before starting another charge. Neither the SDK response nor screen closure authorizes fulfillment.
Continue to Visual customizations and Behavior and support to configure appearance, order rules and tests.