Appearance

Visual style

Mode
Theme
Accent
Advanced
Text sizeScales the whole site
16 px
Reduce motionReduce animations or match your system
Separate light and darkChoose a theme, accent and font for each
50

Technology · Payments

Mercado Pago integration

Mercado Pago is the payments platform of Mercado Libre, operating across Latin America. Its developer documentation covers online payments via cards, PIX in Brazil and other local methods, through Checkout Pro, Checkout Bricks or direct API integration, with webhook notifications for payment status changes.

In practice

How I use Mercado Pago

I implemented Mercado Pago payment flows in Ekonavi's marketplace commerce API, a Hono service on Cloudflare Workers: PIX payments and crypto, webhook handling, and the order lifecycle from checkout through payment to fulfilment. The marketplace is Brazil-based, which makes PIX a core payment method.

Confirming payments on the server

In any payment integration, decide first which system is the source of truth for payment state. In the marketplace API it’s the server:

  1. Checkout creates an order in a pending state and a Mercado Pago payment.
  2. For PIX, the buyer gets a QR code and copy-paste code and pays in their bank app.
  3. Mercado Pago sends a webhook notification to the API.
  4. The API verifies the notification, fetches the payment from Mercado Pago, and only then transitions the order.
  5. Handling is idempotent: a repeated notification for an already-paid order changes nothing.

Verifying notifications

Mercado Pago signs webhook notifications. Per its documentation, the x-signature header carries a timestamp and an HMAC-SHA256 signature computed over a manifest built from the notification’s data ID, the x-request-id header and that timestamp, using the secret configured for your application. Verify that signature and fetch the payment by ID before trusting the status.

// Illustrative verification on Workers (Web Crypto)
const [ts, v1] = parseSignatureHeader(c.req.header("x-signature")); // "ts=...,v1=..."
const manifest = `id:${dataId};request-id:${c.req.header("x-request-id")};ts:${ts};`;
const expected = await hmacSha256Hex(env.MP_WEBHOOK_SECRET, manifest);
if (!timingSafeEqual(expected, v1)) return c.json({ error: "invalid signature" }, 401);
const payment = await mp.payments.get(dataId); // trust the API, not the payload

For the general pattern (verify, enqueue, process idempotently, sweep), see the article on payment webhooks linked below.

Trade-offs

Where Mercado Pago shines, and where it doesn't

Strengths

  • Local payment methods (PIX in particular) that Brazilian buyers expect.
  • PIX settles quickly and is generated as a QR code or copy-paste code, which suits mobile checkout.
  • Webhooks and a payments API for server-side verification.

Limitations

  • Documentation and dashboard features differ by country; test in the market you're launching in.
  • Asynchronous methods like PIX mean the order must wait for a webhook rather than completing in the browser.

Sources

Official documentation

General descriptions on this page are based on the official documentation linked below. Experience notes are my own.

FAQ

Mercado Pago questions

How does a PIX payment work in an online store?

The server creates a payment with PIX as the method and receives a QR code and a copy-paste code. The buyer pays in their banking app. Mercado Pago then sends a webhook notification, and the server fetches the payment to confirm its status before marking the order paid.

Should the order be marked paid when the buyer returns to the site?

No. The browser redirect doesn't prove the customer paid. Orders change state only after the server verifies the payment, triggered by the webhook notification and confirmed with an API call.

Does Mercado Pago support cards as well as PIX?

Yes. In Brazil, Mercado Pago supports credit and debit cards, PIX, boleto and Mercado Pago account balance, among other methods, through Checkout Pro, Checkout Bricks or its payments API. Available methods differ by country.

Need a Mercado Pago developer?

If your project needs Mercado Pago, send a short description of what you're building and where it's stuck. I'll reply with how I'd approach it.