Skip to content

Mercado Pago Setup & Integration Guide

The mercadopago provider integrates Mercado Pago Checkout Pro (Pix, Boleto, OXXO, Cards), Preapproval Subscriptions, and Chargeback Tracking across Latin American markets (BRL, MXN, ARS, CLP, COP, PEN, UYU).


Kirak communicates with Mercado Pago directly via async REST API calls with httpx. No external Mercado Pago SDK or additional pip package is required.

Terminal window
pip install "kirak"

In Mercado Pago Developers (Your Integrations):

  1. Select or create your application.
  2. Under Production credentials or Test credentials, copy the Access Token.

In your application $\rightarrow$ Webhooks:

  1. Set the URL to: https://your-domain.com/payments/webhook/mercadopago.
  2. Select the event topics: Payments, Plans and subscriptions (subscription preapproval and authorized payment), and Chargebacks.
  3. Copy the generated Secret signature.

[!WARNING] Use modern Webhooks, not legacy IPN notifications. IPN deliveries are un-signed and will be rejected with 400 INVALID_WEBHOOK_SIGNATURE.

{
"payments": {
"default_provider": "mercadopago",
"providers": {
"mercadopago": {
"type": "mercadopago",
"environment": "sandbox",
"success_url": "https://your-domain.com/payment/success"
}
}
}
}
Terminal window
KIRAK_PAYMENT_MERCADOPAGO_ACCESS_TOKEN=APP_USR-...
KIRAK_PAYMENT_MERCADOPAGO_WEBHOOK_SECRET=your_secret_signature_from_step2

Supports all methods enabled on your Mercado Pago account (credit/debit cards, Pix in Brazil, Boleto, OXXO in Mexico):

result = await kirak.payments.initiate_payment({
"provider": "mercadopago",
"user_id": "usr_800",
"amount": 4990, # R$ 49.90 in minor units (centavos)
"currency": "BRL",
"name": "Curso Online",
"type": "one_time",
"payment_email": "cliente@example.com.br",
})
checkout_url = result["data"]["url"]

Create a Preapproval Plan in Mercado Pago first:

result = await kirak.payments.initiate_payment({
"provider": "mercadopago",
"user_id": "usr_800",
"amount": 0, # Price defined by preapproval plan
"currency": "BRL",
"name": "Assinatura Mensal",
"type": "subscription",
"subscription_plan_id": "2c9380848...", # Mercado Pago Preapproval Plan ID
"payment_email": "cliente@example.com.br",
})

Mercado Pago supports pausing, resuming, and changing subscription amounts:

# Pause billing:
await kirak.payments.pause_subscription({"subscription_id": "2c938..."})
# Resume billing:
await kirak.payments.resume_subscription({"subscription_id": "2c938..."})
# Cancel subscription (immediate only):
await kirak.payments.cancel_subscription({"subscription_id": "2c938..."})

[!NOTE] Saved Cards & Off-Session Charges: Mercado Pago requires the CVV/CVC security code to be entered by the customer for every charge. Consequently, fully headless off-session charges (charge_off_session) and saved cards without buyer interaction are not supported (501 NOT_SUPPORTED).


Normalized event Gateway Events Description
payment_completed payment (status="approved") Payment approved and settled
payment_failed payment (status="rejected", "cancelled") Payment failed
subscription_renewed subscription_authorized_payment Preapproval cycle billed
subscription_updated subscription_preapproval (status="paused") Subscription paused or modified
subscription_cancelled subscription_preapproval (status="cancelled") Subscription cancelled
refund_completed payment (status="refunded") Refund completed
dispute_created topic_chargebacks_wh Chargeback opened