Test integration
Before going to production, it is essential to test the complete Automatic Payments flow via Orders. This will allow you to verify that the creation of customers, payment profiles, and transactions is done correctly before receiving real payments.
Throughout the process, you must use your test credentialsAccess keys linked to an application and used to test the integration in a secure environment. You can find them in the application's Credentials section, within the test environment. They cannot process real payments. to ensure that the tests work correctly.
Follow the steps below to test your integration.
First, you must tokenize the payment method.
Mercado Pago provides test cards that will allow you to test payments without using a real card.
Their data, such as number, security code, and expiration date, can be combined with the data relating to the cardholder, which will allow you to test different payment scenarios. That is, you can use the information of any test card and test different payment results based on the cardholder's data.
Below, you can see the data of the test debit and credit cards. Select the one you want to use to test your integration.
| Card type | Flag | Number | Security code | Expiration date |
| Credit card | Mastercard | 5031 7557 3453 0604 | 123 | 11/30 |
| Credit card | Visa | 4009 1753 3280 6176 | 123 | 11/30 |
| Credit card | American Express | 3711 803032 57522 | 1234 | 11/30 |
| Debit card | Mastercard | 5178 7816 2220 2455 | 123 | 11/30 |
Next, choose which payment scenario to test and fill in the cardholder's information (First name and last name, Document type and number) as indicated in the table below.
| Payment Status | Cardholder’s first and last name | Identity document |
| Approved payment | APRO | 123456789 |
| Declined for general error | OTHE | 123456789 |
| Pending payment | CONT | - |
| Declined with validation to authorize | CALL | - |
| Declined for insufficient amount | FUND | - |
| Declined for invalid security code | SECU | - |
| Declined due to due date issue | EXPI | - |
| Declined due to form error | FORM | - |
| Rejected for missing card_number | CARD | - |
| Rejected for invalid installments | INST | - |
| Rejected for duplicate payment | DUPL | - |
| Rejected for disabled card | LOCK | - |
| Rejected for non-permitted card type | CTNA | - |
| Rejected due to exceeded PIN attempts | ATTE | - |
| Rejected for being on the blacklist | BLAC | - |
| Not supported | UNSU | - |
| Used to apply amount rules | TEST | - |
Continue registering the tokenized test card in your system, following the steps according to the business model your integration adapts to. Remember to use your test Access TokenPrivate key linked to an application, used in the backend to authenticate operations in the test environment. You can find it in the application's Credentials section, within the test environment. It cannot process real payments, must never be exposed in the frontend, and starts with the `APP_USR` prefix..
As the customer email, use the format testuser{number}@testuser.com (for example, testuser123456789@testuser.com).
With the customer_id and payment_profile_id generated in the previous stage, you can now process an automatic test payment.
Send a request to the endpoint /v1/orders including your test Access TokenPrivate key linked to an application, used in the backend to authenticate operations in the test environment. You can find it in the application's Credentials section, within the test environment. It cannot process real payments, must never be exposed in the frontend, and starts with the `APP_USR` prefix. and following the detailed instructions for each payment type.
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": "100.00", "external_reference": "test-order-001", "payer": { "customer_id": "CUSTOMER_ID" }, "transactions": { "payments": [ { "amount": "100.00", "automatic_payments": { "payment_profile_id": "PAYMENT_PROFILE_ID" }, "stored_credential": { "payment_initiator": "merchant", "reason": "card_on_file", "first_payment": true } } ] } }'
| Parameter | Type | Description | Required |
type | String | Order type. Must be online. | Required |
external_reference | String | External reference of the order. Maximum 64 alphanumeric characters, hyphens (-) and underscores (_). | Required |
total_amount | String | Total amount of the transaction. | Required |
payer.customer_id | String | Customer identifier, obtained in step 2. | Required |
transactions.payments.amount | String | Transaction amount. | Required |
automatic_payments.payment_profile_id | String | Payment profile identifier, obtained in step 2. | Required |
stored_credential.payment_initiator | String | Indicates who initiates the transaction. Use merchant for MIT payments or customer for CIT payments. | Required |
stored_credential.reason | String | Payment reason. For one-time payments with saved card, use card_on_file. | Optional |
stored_credential.first_payment | Boolean | Indicates if it is the first payment (true) or a subsequent payment (false). | Optional |
stored_credential.previous_transaction_reference | String | Reference code of the previous transaction. | Required when first_payment is false |
If you want to test another payment scenario, repeat the request making sure to include the data associated with the second tokenized test card.
To verify that the test payment was processed correctly, send a request to the endpoint /v1/orders/{id}GET replacing {id} with the order identification received in the response from the previous step.
The response should show the payment status selected when entering the test cardholder data.
json{ "id": "ORD01JS2V6CM8KJ0EC4H502TGK1WP", "type": "online", "processing_mode": "automatic", "status": "processed", "status_detail": "accredited", "total_amount": "100.00", "transactions": { "payments": [ { "id": "PAY01JS2V6CM8KJ0EC4H504R7YE34", "amount": "100.00", "status": "processed", "status_detail": "accredited" } ] } }
Additionally, you can verify that you received the Webhook notification with the order data.