← ClaudeAtlas

ekx-mercadopagolisted

MercadoPago checkout for the Colombian market, as used for course enrollment — the official Node SDK v2, Preference creation in COP, x-signature webhook verification with replay protection, and the idempotent status-transition guard that keeps a retried webhook from downgrading a paid enrollment. Use when taking payment in COP, building a checkout redirect, handling an MP webhook, or debugging a payment that flipped back to pending.
Ekinoxis-evm/claude-skills · ★ 0 · AI & Automation · score 60
Install: claude install-skill Ekinoxis-evm/claude-skills
# MercadoPago The Colombian payment rail. **Live in exactly one place** — course enrollment. Stripe does not serve Colombia well; this is the reason MercadoPago exists in the portfolio at all. Everything below is extracted from a `mercadopago.ts` / `mpWebhookDecision.ts` pair, both of which have unit tests. ## Setup ```bash npm i mercadopago # official SDK v2 — github.com/mercadopago/sdk-nodejs ``` ``` MERCADOPAGO_ACCESS_TOKEN= # server-only, never NEXT_PUBLIC_ MERCADOPAGO_WEBHOOK_SECRET= # from the MP dashboard, webhook config ``` ```ts import MercadoPagoConfig, { Preference, Payment } from "mercadopago"; function getClient(): MercadoPagoConfig { const token = process.env.MERCADOPAGO_ACCESS_TOKEN; if (!token) throw new Error("MERCADOPAGO_ACCESS_TOKEN is not set"); return new MercadoPagoConfig({ accessToken: token }); } ``` ## Checkout — create a Preference, redirect to `init_point` MP is **redirect-based**, not an embedded element like Stripe's Payment Element. You create a Preference server-side and send the user to the URL it returns. ```ts const preference = new Preference(getClient()); const response = await preference.create({ body: { items: [{ id: `course-${courseId}`, title: courseName, quantity: 1, unit_price: unitPrice, // final price AFTER discount currency_id: "COP", }], payer: { email: buyerEmail }, back_urls: { success: `${baseUrl}/academia?payment=success`, failure: `${bas