Mercado Pago via Direct API
Integrate Mercado Pago through the DEUNA API, test the payment lifecycle, and verify the final status safely.
Integrate Mercado Pago in your application via API.
1. Create and order#
To make a purchase, create an order in DEUNA.
Make a request to the Create an Order endpoint.
The API returns an order_token that is used throughout the flow.
Request example
{
"order_type": "AIRLINE_ORDER",
"order": {
....
"statement_descriptor": "DEUNA_TICKET",
"store_code": "all",
"airline_information": {
"booking_items": [
{
"passenger": {
"first_name": "Jhon",
"middle_name": "Paul",
"last_name": "Smith",
"date_of_birth": "2000-06-27"
},
"legs": [
{
"carrier_name": "Aeromexico",
"sub_total_amount": 900,
"tax_amount": 600,
"total_amount": 1500,
"origin": {
"date": "2020-02-15",
"time": "15:30",
"iata_code": "SFO"
},
"destination": {
"iata_code": "DBX",
"date": "2020-02-15",
"time": "15:30"
}
}
]
}
]
}
}
}Field description
Learn how all fields must be filled in the Mercado Pago order via API.
Common fields in all orders:
| Field Path | Description | Example Value |
|---|---|---|
| order_type | Type of the order (it must be AIRLINE_ORDER if airline information is present) | AIRLINE_ORDER |
| order.statement_descriptor | Statement description for payment. Maximum length accepted by Mercado Pago: 13 characters. | DEUNA*SHOP123 |
Passenger required fields
For each passenger, fill in personal information and each of the purchased leg.
| Field Path | Description | Example Value | Required |
|---|---|---|---|
| order.airline_information.booking_items[0].passenger.first_name | Passenger first name | John | |
| order.airline_information.booking_items[0].passenger.middle_name | Passenger middle name (if applicable) | Paul | Optional |
| order.airline_information.booking_items[0].passenger.last_name | Passenger last name | Smith | |
| order.airline_information.booking_items[0].passenger.date_of_birth | Passenger date of birth | 2000-06-27 | Optional |
| order.airline_information.booking_items[0].legs[0].carrier_name | Airline carrier code | Aeroméxico | Default value "Unknown" |
| order.airline_information.booking_items[0].legs[0].total_amount | Total amount for the leg | 1000 | |
| order.airline_information.booking_items[0].legs[0].sub_total_amount | Subtotal for the leg without taxes | 1000 | |
| order.airline_information.booking_items[0].legs[0].tax_amount | Tax amount | 0 | Optional |
| order.airline_information.booking_items[0].legs[0].origin.date | Origin date | 2020-02-15 | |
| order.airline_information.booking_items[0].legs[0].origin.time | Origin time | 15:30 | |
| order.airline_information.booking_items[0].legs[0].origin.iata_code | Origin airport IATA code | SFO | Default value "N/A” |
| order.airline_information.booking_items[0].legs[0].destination.iata_code | Destination airport IATA code | DBX | Default value "N/A” |
| order.airline_information.booking_items[0].legs[0].destination.date | Destination date | 2020-02-15 | |
| order.airline_information.booking_items[0].legs[0].destination.time | Destination time | 15:30 |
Order fields
| Field | Description | Example Value | Required |
|---|---|---|---|
| order.store_code | Unique store code (value “all”) | all | |
| order.items | Collection of items. Check | Create an Order | Required by this Mercado Pago flow if airline information is not included. |
| order.statement_descriptor | Statement description for payment. Maximum length accepted by Mercado Pago: 13 characters. | DEUNA\SHOP123 |
General considerations:
- About
order.items:total_amount.original_amountmust beunit_price.amount * quantity.total_amount.amountmust be((unit_price.amount + tax_amount.amount) * quantity) - total_amount.total_discount.total_amount.total_discountis the total value of discounts for the quantity of items.
order.items_total_amountis the sum of the unit prices of the items. This amount, plusorder.total_tax_amountand minusorder.discount_amount, must matchorder.total_amount.order.sub_totalis the sum of the unit price of the items minus the discounts. This amount, plusorder.total_tax_amount, must matchorder.total_amount.
2. callback_urls to for Deep Links#
When Mercado Pago opens in a native browser surface (SafariViewController on iOS or Custom Tabs on Android), you must configure deep links so the user returns to your app after the payment outcome.
{
"order_type": "AIRLINE_ORDER",
"order": {
.
.
.
"callback_urls": {
"on_success": "yourapp://success",
"on_pending": "yourapp://pending",
"on_failed": "yourapp://failed"
}
}
}3. Process the order#
Make a request to the V2 Purchase endpoint an process the payment.