Cards
The integration of payments with credit and/or debit cards in Checkout API can be done in two ways. The recommended integration is through the Card Payment Brick, where the Brick takes care of retrieving the necessary information to process the payment. However, if you prefer to be responsible for determining how this information will be retrieved, you can perform your integration using Core Methods, available for websites.
In the integration through the Card Payment for websites, the MercadoPago.js library, included in your project during the configuration of the development environment, is responsible for obtaining the information required for processing a payment. This means it searches for the types of documents available for the corresponding country, and as the card data is entered, it also retrieves information related to the issuer and the available installments.
All information involved in processing the transaction is stored in the backend, in compliance with PCI security standards.
In addition, the component provides the ability to guide the user with alerts for incomplete fields or possible errors when filling out the data, optimizing the purchasing process.
With this, the implementation of the flow is transparent for those who are performing the integration, as shown in the diagram below.
sequenceDiagram
participant Buyer's Browser
participant Integrator Frontend
participant MercadoPago.js
participant Integrator Backend
participant Mercado Pago API
Buyer's Browser->>Integrator Frontend: 1. The buyer accesses the payment screen.
Integrator Frontend->>MercadoPago.js: 2. The integrator's frontend downloads and initializes Mercado Pago's JS SDK.
Integrator Frontend->>Buyer's Browser: 3. The integrator's frontend displays the payment form.
Buyer's Browser->>Integrator Frontend: 4. The buyer completes the form and submits the payment.
Integrator Frontend->>MercadoPago.js: 5. The integrator's frontend uses the JS SDK to create a token containing the card data securely.
Integrator Frontend->>Integrator Backend: 6. The integrator's frontend sends the card token and payment data to its backend.
Integrator Backend->>Mercado Pago API: 7. The backend calls Mercado Pago services to create the payment.
Mercado Pago API->>Buyer's Browser: 8. The integrator's frontend shows the buyer the result of the transaction.
Mercado Pago API->>Integrator Backend: 9. Mercado Pago may send notifications via Webhook with payment status updates.
Integrator Backend->>Buyer's Browser: 10. If applicable, the buyer is notified about the payment update.
To proceed with the setup of debit and/or credit card payments via Card Payment, follow the steps below.
processing_mode parameter. For more information, visit the section Integration model.To receive payments, you need to add a form in the frontend that allows for securely capturing the payer's information and enables card encryption.
This inclusion should be done through the Card Payment, which offers an optimized form with various themes and includes the necessary fields for card payments.
To add the Card Payment, first configure and initialize it from the frontend, as shown in the examples below.
const renderCardPaymentBrick = async (bricksBuilder) => {
const settings = {
initialization: {
amount: 100.99, // total amount to be paid
},
callbacks: {
onReady: () => {
/*
Callback called when Brick is ready.
Here you can hide loadings from your site, for example.
*/
},
onSubmit: (formData, additionalData) => {
// callback called when clicking on the submit data button
return new Promise((resolve, reject) => {
const submitData = {
type: "online",
total_amount: String(formData.transaction_amount), // should be a string in the format 00.00
external_reference: "ext_ref_1234", // identifier of the transaction source
processing_mode: "automatic",
transactions: {
payments: [
{
amount: String(formData.transaction_amount), // should be a string in the format 00.00
payment_method: {
id: formData.payment_method_id,
type: additionalData.paymentTypeId,
token: formData.token,
installments: formData.installments,
},
},
],
},
payer: {
email: formData.payer.email,
identification: formData.payer.identification,
},
};
fetch("/process_order", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(submitData),
})
.then((response) => response.json())
.then((response) => {
// receive payment result
resolve();
})
.catch((error) => {
// handle error response when trying to create payment
reject();
});
});
},
onError: (error) => {
// callback called for all Brick error cases
console.error(error);
},
},
};
window.cardPaymentBrickController = await bricksBuilder.create(
"cardPayment",
"cardPaymentBrick_container",
settings
);
};
renderCardPaymentBrick(bricksBuilder);
The onSubmit callback of the Brick will obtain the minimum necessary data for creating a payment. Among those minimal data, there is the CardToken, that safely represents the card data. This token can only be used once, and will expire within 7 days.
In addition to the minimum data, we recommend collecting additional details or those that can facilitate the recognition of the purchase by the buyer, thus increasing the payment approval rate. Consult our API ReferenceAPI for detailed information on all the parameters to be sent when creating a payment, including those that could improve your approval rate, and check which ones you want to include at this stage.
Then, add the relevant fields to the object being sent, which are returned in the callback response.
window.cardPaymentBrickController.unmount(). When entering again, a new instance must be generated.
Finally, render the Brick using one of the examples below.<div id="cardPaymentBrick_container"></div> // The ID must match the value sent in the create() method in the previous step
As a result, the rendering of the Brick will look similar to the image below.

To move on to the payment submission stage, your backend must be able to receive the information from the created form, along with the token resulting from the card encryption. For this, we recommend providing an endpoint /Process_order that accommodates the data collected by the Brick after performing the submit action.
The payment submission must be made by creating an order that contains associated payment transactions.
To do this, send a request with your test Access TokenPrivate key of the application created in Mercado Pago, that must be used in the backend. You can access it through Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`. and the required parameters listed below to the endpoint /v1/ordersPOST.
curlcurl -X POST \ 'https://api.mercadopago.com/v1/orders'\ -H 'Content-Type: application/json' \ -H 'X-Idempotency-Key: {{SOME_UNIQUE_VALUE}}' \ -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}' \ -d '{ "type": "online", "processing_mode": "automatic", "total_amount": "50.00", "external_reference": "ext_ref_1234", "payer": { "email": "test@testuser.com" }, "transactions": { "payments": [ { "amount": "50.00", "payment_method": { "id": "master", "type": "credit_card", "token": "1223123", "installments": 1 } } ] } }'
429 Too Many Requests error, wait the time indicated in the Retry-After response header before retrying. See Possible errors for more details.See the table below for descriptions of the parameters that have some important particularity that should be highlighted.
| Parameter | Type | Description | Requirement |
Authorization | Header | Refers to your private key, the test Access TokenPrivate key of the application created in Mercado Pago, that must be used in the backend. You can access it through Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`.. | Required |
X-Idempotency-Key | Header | Idempotency key. It is used to ensure that each request is processed only once, avoiding duplications. Use a unique value in the header of your request, such as a UUID V4 or random strings. | Required |
processing_mode | Body. String | Processing mode of the order. The possible values are: - automatic: to create and process the order in automatic mode. - manual: to create the order and process it later. For more information, visit the section Integration model. | Required |
total_amount | Body. String | Total amount for the transaction. | Required |
transaction.payments.payment_method.id | Body. String | Payment method identifier. In this case, it is the brand of each card. You can check the complete list of available identifiers by sending a request to the Get payment methodsGET endpoint. | Required |
transaction.payments.payment_method.type | Body. String | Payment method type. For credit card payments, it should be credit_card, and for debit card payments, it should be debit_card. | Required |
transaction.payments.payment_method.token | Body. String | Card token. Required for credit and debit card payments. | Required |
In case of success, the response will look like the example below.
json{ "id": "ORD01JS2V6CM8KJ0EC4H502TGK1WP", "type": "online", "processing_mode": "automatic", "external_reference": "ext_ref_1234", "total_amount": "50.00", "total_paid_amount": "50.00", "country_code": "BRA", "user_id": "2021490138", "status": "processed", "status_detail": "accredited", "capture_mode": "automatic", "created_date": "2025-04-17T21:41:33.96Z", "last_updated_date": "2025-04-17T21:41:35.144Z", "integration_data": { "application_id": "874202490252970" }, "transactions": { "payments": [ { "id": "PAY01JS2V6CM8KJ0EC4H504R7YE34", "amount": "50.00", "paid_amount": "50.00", "reference_id": "0002yjis6j", "status": "processed", "status_detail": "accredited", "payment_method": { "id": "elo", "type": "credit_card", "token": "519ada5ac7431ef6ce24ac19c38f6768", "installments": 1 } } ] } }
Among the returned parameters, the ones indicated in the table below stand out.
| Parameter | Type | Description |
transactions.payments.status | String | Transaction status. For example, processed indicates the payment was approved. See the Transaction status section for all possible values. |
transactions.payments.status_detail | String | Transaction status detail. For example, accredited indicates the payment was approved and credited. |
transactions.payments.paid_amount | String | Amount actually paid in the transaction. |