Manejo de Órdenes de Carrito

Con el desembarco de esta nueva funcionalidad se verá un cambio en la estructura del JSON en el recurso Orders. La principal diferencia será que la información del envío ya no estará disponible aquí dentro, sino que solo estará el ID asociado, para luego ir a buscar la data complementaria al recurso /shipments.
Nota: Recuerda que para trabajar con el JSON actualizado, al hacer el GET deberás enviar el parámetro "x-format-new: true". El resto de la estructura del recurso seguirá funcionando de la misma manera, con algunas modificaciones que deberás tener en cuenta.

curl -X GET -H x-format-new: true https://api.mercadolibre.com/orders/order_id?access_token=ACCESS_TOKEN


JSON previo

{
    "id": 2053577644,
    "date_created": "2019-06-13T09:20:02.000-04:00",
    "date_closed": "2019-06-13T09:20:08.000-04:00",
    "last_updated": "2019-06-13T09:20:08.000-04:00",
    "manufacturing_ending_date": null,
    "feedback": {
        "sale": null,
        "purchase": null
    },
    "mediations": [],
    "comments": null,
    "pack_id": 2000000101334825,
    "pickup_id": null,
    "order_request": {
        "return": null,
        "change": null
    },
    "fulfilled": null,
    "total_amount": 9.99,
    "total_amount_with_shipping": 20.04,
    "paid_amount": 20.04,
    "coupon": {
        "id": null,
        "amount": 0
    },
    "expiration_date": "2019-07-11T09:20:08.000-04:00",
    "order_items": [
        
            "item": {
                "id": "MLB1226730704",
                "title": "Produto Teste - Não Ofertar",
                "category_id": "MLB11742",
                "variation_id": null,
                "seller_custom_field": null,
                "variation_attributes": [],
                "warranty": "12 months",
                "condition": "new",
                "seller_sku": null
            },
            "quantity": 1,
            "unit_price": 9.99,
            "full_unit_price": 9.99,
            "currency_id": "BRL",
            "manufacturing_days": null
        
    ],
    "currency_id": "BRL",
    "payments": [
        
            "id": 4863317779,
            "order_id": 2053577644,
            "payer_id": 419067349,
            "collector": {
                "id": 419059118
            },
            "card_id": null,
            "site_id": "MLB",
            "reason": "Produto Teste - Não Ofertar",
            "payment_method_id": "account_money",
            "currency_id": "BRL",
            "installments": 1,
            "issuer_id": null,
            "atm_transfer_reference": {
                "company_id": null,
                "transaction_id": null
            },
            "coupon_id": null,
            "activation_uri": null,
            "operation_type": "regular_payment",
            "payment_type": "account_money",
            "available_actions": [
                "refund"
            ],
            "status": "approved",
            "status_code": null,
            "status_detail": "accredited",
            "transaction_amount": 9.99,
            "taxes_amount": 0,
            "shipping_cost": 0,
            "coupon_amount": 0,
            "overpaid_amount": 0,
            "total_paid_amount": 9.99,
            "installment_amount": null,
            "deferred_period": null,
            "date_approved": "2019-06-13T09:20:07.000-04:00",
            "authorization_code": null,
            "transaction_order_id": null,
            "date_created": "2019-06-13T09:20:07.000-04:00",
            "date_last_modified": "2019-06-13T09:20:07.000-04:00"
        },
        
            "id": 4863151808,
            "order_id": 2053577644,
            "payer_id": 419067349,
            "collector": {
                "id": 419059118
            },
            "card_id": null,
            "site_id": "MLB",
            "reason": "marketplace_shipment",
            "payment_method_id": "account_money",
            "currency_id": "BRL",
            "installments": 1,
            "issuer_id": null,
            "atm_transfer_reference": {
                "company_id": null,
                "transaction_id": null
            },
            "coupon_id": null,
            "activation_uri": null,
            "operation_type": "regular_payment",
            "payment_type": "account_money",
            "available_actions": [
                "refund"
            ],
            "status": "approved",
            "status_code": null,
            "status_detail": "accredited",
            "transaction_amount": 10.05,
            "taxes_amount": 0,
            "shipping_cost": 0,
            "coupon_amount": 0,
            "overpaid_amount": 0,
            "total_paid_amount": 10.05,
            "installment_amount": null,
            "deferred_period": null,
            "date_approved": "2019-06-13T09:20:07.000-04:00",
            "authorization_code": null,
            "transaction_order_id": null,
            "date_created": "2019-06-13T09:20:07.000-04:00",
            "date_last_modified": "2019-06-13T09:20:07.000-04:00"
        
    ],
    "shipping": {
        "id": 27987243797,
        "site_id": "MLB",
        "shipment_type": "shipping",
        "mode": "me1",
        "shipping_mode": "me1",
        "status": "pending",
        "substatus": "shipment_paid",
        "date_created": "2019-06-13T09:20:03.000-04:00",
        "receiver_address": {
            "id": 1036317458,
            "address_line": "Rua Direita 123, ",
            "street_name": "Rua Direita",
            "street_number": "123",
            "comment": null,
            "zip_code": "04567000",
            "city": {
                "id": "BR-SP-44",
                "name": "São Paulo"
            },
            "state": {
                "id": "BR-SP",
                "name": "São Paulo"
            },
            "country": {
                "id": "BR",
                "name": "Brasil"
            },
            "neighborhood": {
                "id": null,
                "name": "Centro"
            },
            "municipality": {
                "id": null,
                "name": null
            },
            "agency": null,
            "types": [
                "default_buying_address"
            ],
            "latitude": -23.729929,
            "longitude": -46.680368,
            "geolocation_type": "ROOFTOP",
            "receiver_name": "Teste Teste",
            "receiver_phone": "11999999999"
        },
        "sender_address": {
            "id": 1032937241,
            "address_line": "Rua de Teste 123",
            "street_name": "Rua da Teste",
            "street_number": "123",
            "comment": null,
            "zip_code": "05678100",
            "city": {
                "id": "BR-SP-44",
                "name": "São Paulo"
            },
            "state": {
                "id": "BR-SP",
                "name": "São Paulo"
            },
            "country": {
                "id": "BR",
                "name": "Brasil"
            },
            "neighborhood": {
                "id": null,
                "name": "bairro teste"
            },
            "municipality": {
                "id": null,
                "name": null
            },
            "agency": null,
            "types": [
                "billing",
                "default_selling_address",
                "shipping"
            ],
            "latitude": -23.625124,
            "longitude": -46.744142,
            "geolocation_type": "ROOFTOP"
        },
        "currency_id": "BRL",
        "date_first_printed": null,
        "service_id": null,
        "shipping_items": [
            
                "id": "MLB1226730704",
                "description": "Produto Teste - Não Ofertar",
                "quantity": 1,
                "dimensions": "10.0x18.0x28.0,300.0",
                "dimensions_source": {
                    "id": "MLB11742",
                    "origin": "categories"
                
            
        ],
        "receiver_id": 419067349,
        "sender_id": 419059118,
        "shipping_option": {
            "id": 40000048146400001,
            "shipping_method_id": 182,
            "name": "Expresso",
            "currency_id": "BRL",
            "list_cost": 10.05,
            "cost": 10.05,
            "delivery_type": "estimated",
            "estimated_schedule_limit": {
                "date": null
            },
            "estimated_delivery_time": {
                "type": "known_frame",
                "date": "2019-06-18T00:00:00.000-03:00",
                "unit": "hour",
                "offset": {
                    "date": "2019-06-19T00:00:00.000-03:00",
                    "shipping": 24
                },
                "time_frame": {
                    "from": null,
                    "to": null
                },
                "pay_before": null,
                "shipping": 24,
                "handling": 48,
                "schedule": null
            },
            "estimated_delivery_limit": {
                "date": "2019-07-04T00:00:00.000-03:00",
                "offset": 240
            },
            "estimated_delivery_final": {
                "date": "2019-10-11T00:00:00.000-03:00",
                "offset": 1920
            },
            "estimated_delivery_extended": {
                "date": "2019-06-27T00:00:00.000-03:00",
                "offset": 120
            },
            "estimated_handling_limit": {
                "date": "2019-06-17T00:00:00.000-03:00"
            
        },
        "logistic_type": "default",
        "picking_type": null,
        "cost_components": {
            "special_discount": 0,
            "loyal_discount": 0,
            "compensation": 0,
            "gap_discount": 0,
            "ratio": 0
        },
        "cost": 10.05
    },
    "status": "paid",
    "status_detail": null,
    "tags": [
        "test_order",
        "pack_order",
        "not_delivered",
        "paid"
    ],
    "buyer": {
        "id": 419067349,
        "nickname": "TT763866",
        "email": "ttest.6hqmq6+2-ogiydkmzvg43tmobx@mail.mercadolivre.com",
        "phone": {
            "area_code": "01",
            "extension": "",
            "number": "1111-1111",
            "verified": false
        },
        "alternative_phone": {
            "area_code": "",
            "extension": "",
            "number": ""
        },
        "first_name": "Test",
        "last_name": "Test",
        "billing_info": {
            "doc_type": "CPF",
            "doc_number": "78525276200"
        
    },
    "seller": {
        "id": 419059118,
        "nickname": "TETE8288849",
        "email": "ttest.hpz2z6q+2-ogiydkmzvg43tmobs@mail.mercadolivre.com",
        "phone": {
            "area_code": "01",
            "extension": "",
            "number": "1111-1111",
            "verified": false
        },
        "alternative_phone": {
            "area_code": "",
            "extension": "",
            "number": ""
        },
        "first_name": "Test",
        "last_name": "Test"
    },
    "taxes": {
        "amount": null,
        "currency_id": null
    
}


JSON nuevo

{
    "id": 2053577644,
    "date_created": "2019-06-13T09:20:02.000-04:00",
    "date_closed": "2019-06-13T09:20:08.000-04:00",
    "last_updated": "2019-06-13T09:20:08.000-04:00",
    "manufacturing_ending_date": null,
    "feedback": {
        "sale": null,
        "purchase": null
    },
    "mediations": [],
    "comments": null,
    "pack_id": 2000000101334825,
    "pickup_id": null,
    "order_request": {
        "return": null,
        "change": null
    },
    "fulfilled": null,
    "total_amount": 9.99,
    "paid_amount": 9.99,
    "coupon": {
        "id": null,
        "amount": 0
    },
    "expiration_date": "2019-07-11T09:20:08.000-04:00",
    "order_items": [
        
            "item": {
                "id": "MLB1226730704",
                "title": "Produto Teste - Não Ofertar",
                "category_id": "MLB11742",
                "variation_id": null,
                "seller_custom_field": null,
                "variation_attributes": [],
                "warranty": "12 months",
                "condition": "new",
                "seller_sku": null
            },
            "quantity": 1,
            "unit_price": 9.99,
            "full_unit_price": 9.99,
            "currency_id": "BRL",
            "manufacturing_days": null
        
    ],
    "currency_id": "BRL",
    "payments": [
        
            "id": 4863317779,
            "order_id": 2053577644,
            "payer_id": 419067349,
            "collector": {
                "id": 419059118
            },
            "card_id": null,
            "site_id": "MLB",
            "reason": "Produto Teste - Não Ofertar",
            "payment_method_id": "account_money",
            "currency_id": "BRL",
            "installments": 1,
            "issuer_id": null,
            "atm_transfer_reference": {
                "company_id": null,
                "transaction_id": null
            },
            "coupon_id": null,
            "activation_uri": null,
            "operation_type": "regular_payment",
            "payment_type": "account_money",
            "available_actions": [
                "refund"
            ],
            "status": "approved",
            "status_code": null,
            "status_detail": "accredited",
            "transaction_amount": 9.99,
            "taxes_amount": 0,
            "shipping_cost": 0,
            "coupon_amount": 0,
            "overpaid_amount": 0,
            "total_paid_amount": 9.99,
            "installment_amount": null,
            "deferred_period": null,
            "date_approved": "2019-06-13T09:20:07.000-04:00",
            "authorization_code": null,
            "transaction_order_id": null,
            "date_created": "2019-06-13T09:20:07.000-04:00",
            "date_last_modified": "2019-06-13T09:20:07.000-04:00"
        
    ],
    "shipping": {
        "id": 27987243797
    },
    "status": "paid",
    "status_detail": null,
    "tags": [
        "test_order",
        "pack_order",
        "paid"
    ],
    "buyer": {
        "id": 419067349,
        "nickname": "TT763866",
        "email": "ttest.6hqmq6+2-ogiydkmzvg43tmobx@mail.mercadolivre.com",
        "phone": {
            "area_code": "01",
            "extension": "",
            "number": "1111-1111",
            "verified": false
        },
        "alternative_phone": {
            "area_code": "",
            "extension": "",
            "number": ""
        },
        "first_name": "Test",
        "last_name": "Test",
        "billing_info": {
            "doc_type": "CPF",
            "doc_number": "78525276200"
        
    },
    "seller": {
        "id": 419059118,
        "nickname": "TETE8288849",
        "email": "ttest.hpz2z6q+2-ogiydkmzvg43tmobs@mail.mercadolivre.com",
        "phone": {
            "area_code": "01",
            "extension": "",
            "number": "1111-1111",
            "verified": false
        },
        "alternative_phone": {
            "area_code": "",
            "extension": "",
            "number": ""
        },
        "first_name": "Test",
        "last_name": "Test"
    },
    "taxes": {
        "amount": null,
        "currency_id": null
    
}


Para entender a qué hace referencia cada uno de los parámetros realiza la siguiente llamada:

GET https://api.mercadolibre.com/orders/order_id?options&access_token=token

Revisa la documentación de Recurso de Órdenes para ver más información.


Consideraciones:

  • El tag “pack_order” se genera de manera automática para poder discriminar si la orden está asociada a un carrito y no podrá ser borrado por el comprador o el vendedor.

  • El campo "pack_id" muestra el número de carrito al cual pertenece la orden.

  • En caso que la orden no esté asociada a un Carrito de Compras y la transacción sea bajo la modalidad “acordar con el vendedor”, ya no recibirás un status to be agreed si no que directamente el shipping ID vendrá como nule. Eso te dará la pauta de que deberás entrar en contacto con el comprador para coordinar la forma de envío.

  • Solo contarás con el ID del envío, para luego ir a buscar la información a los nuevos recursos de Shipping.

  • Existe la posibilidad de que, aún existiendo una orden, el envío demore en crearse. En esos casos el ID será nulo hasta su creación. Cuando eso pase, serás notificado.

  • Los tags “delivered/not delivered” ya no se agregarán automáticamente. Solamente existirá la marca si el integrador realiza un PUT con el tag definido.

  • Las órdenes en status paid se cancelarán si se rechaza o devuelve el pago. Si sucede, recibirás una notificación para que puedas conocer el cambio en el estado de la orden.

  • Ten en cuenta que la Orden seguirá mostrando el campo "seller_custom_field", pero mostrará los datos cargados con los siguientes criterios usados para escoger la información de SKU 1- SELLER_SKU de atributos de variación 2- seller_custom_field de variación 3- SELLER_SKU de atributos de item 4- seller_custom_field de item.


Siguiente: Manejo de envíos.

Forma parte de nuestra comunidad