Mercado Pago via API

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.

📘

For a detailed information about the description of each field refer to Create an Order .

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"
                            }
                        }
                    ]
                }
            ]
        }
    }
}

📘

total_amount is equal to sub_total_amount + tax_amount in order.airline_information.booking_items.legs.

Field description

Learn how all fields must be filled in the Mercado Pago order via API.

Common fields in all orders:

Field PathDescriptionExample Value
order_typeType of the order (it must be AIRLINE_ORDER if airline information is present)AIRLINE_ORDER
order.statement_descriptorStatement 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.

📘

If airline information is not included, a collection of items must be provided:

Field PathDescriptionExample ValueRequired
order.airline_information.booking_items[0].passenger.first_namePassenger first nameJohn
order.airline_information.booking_items[0].passenger.middle_namePassenger middle name (if applicable)PaulOptional
order.airline_information.booking_items[0].passenger.last_namePassenger last nameSmith
order.airline_information.booking_items[0].passenger.date_of_birthPassenger date of birth2000-06-27Optional
order.airline_information.booking_items[0].legs[0].carrier_nameAirline carrier codeAeroméxicoDefault value "Unknown"
order.airline_information.booking_items[0].legs[0].total_amountTotal amount for the leg1000
order.airline_information.booking_items[0].legs[0].sub_total_amountSubtotal for the leg without taxes1000
order.airline_information.booking_items[0].legs[0].tax_amountTax amount0Optional
order.airline_information.booking_items[0].legs[0].origin.dateOrigin date2020-02-15
order.airline_information.booking_items[0].legs[0].origin.timeOrigin time15:30
order.airline_information.booking_items[0].legs[0].origin.iata_codeOrigin airport IATA codeSFODefault value "N/A”
order.airline_information.booking_items[0].legs[0].destination.iata_codeDestination airport IATA codeDBXDefault value "N/A”
order.airline_information.booking_items[0].legs[0].destination.dateDestination date2020-02-15
order.airline_information.booking_items[0].legs[0].destination.timeDestination time15:30

📘

All amounts must be expressed in cents

Order fields

FieldDescriptionExample ValueRequired
order.store_codeUnique store code (value “all”)all
order.itemsCollection of items. CheckCreate an Order Required if airline information is not included.
order.statement_descriptorStatement description for payment. Maximum length accepted by Mercado Pago: 13 characters.DEUNA\SHOP123

General considerations:

  • About order.items:
    • total_amount.original_amount must be unit_price.amount * quantity.
    • total_amount.amount must be ((unit_price.amount + tax_amount.amount) * quantity) - total_amount.total_discounts.
    • total_amount.total_discounts is the total value of discounts for the quantity of items.
  • order.items_total_amount is the sum of the unit prices of the items. This amount, plus order.total_tax_amount and minus order.discount_amount, must match order.total_amount.
  • order.sub_total is the sum of the unit price of the items minus the discounts. This amount, plus order.total_tax_amount, must match order.total_amount.

2. Process the order

Make a request to the V2 Purchase endpoint an process the payment.