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 that identify your test user, used in development stages or to test the integration. You can access them through Your integrations > Application details > Tests > Test credentials. 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 | 4509 9535 6623 3704 | 123 | 11/30 |
| Credit card | American Express | 3711 803032 57522 | 1234 | 11/30 |
| Debit card | Mastercard | 5287 3383 1025 3304 | 123 | 11/30 |
| Debit card | Visa | 4002 7686 9439 5619 | 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 | (DNI) 12345678 |
| Declined for general error | OTHE | (DNI) 12345678 |
| 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.
You must use your test Access TokenPrivate key of the application created in Mercado Pago, which is used in the backend. You can access it through Your integrations > Application details > Tests > Test credentials. in all requests and use the value test@testuser.com as the customer email.
With the customer_id and payment_profile_id generated in the previous stage, you can now process an automatic test payment.
Send a POST to the endpoint /v1/orders including your test Access TokenPrivate key of the application created in Mercado Pago, which is used in the backend. You can access it through Your integrations > Application details > Tests > Test credentials. and following the detailed instructions for each payment type.
curl
curl -X POST \ 'https://api.mercadopago.com/v1/orders' \ -H 'Content-Type: application/json' \ -H 'X-Idempotency-Key: UNIQUE_IDEMPOTENCY_KEY' \ -H 'Authorization: Bearer TEST-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 GET to the endpoint /v1/orders/{id}API 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.
