• Модуль интеграций
  • Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Представляем готовый к продакшену Medusa DTC Starter от Gorgo

26 августа 2026 г. · Продукт

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Модуль интеграций
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
Mercadopago logo

Mercadopago

Принимайте платежи по всей Латинской Америке

npm install @nicogorga/medusa-payment-mercadopago
Категория
Платежи
Создано
Nicolas Gorga
Версия
0.4.0
Последнее обновление
3 недели назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
0
npmNPM

@nicogorga/medusa-payment-mercadopago

Receive payments on your Medusa commerce application using Mercado Pago.

Medusa Payment Mercadopago Repository | Medusa Website | Medusa Repository

[!WARNING] This plugin is a WIP and has only been tested for Credit / Debit Card methods following Mercado Pago docs for Uruguay. You can sumbit issues through GitHub Issues. Feel free to make contributions by making pull requests and proposing ideas / new flows to implement via Discussions

Features

  • Mercado Pago integration via Checkout API
  • Payments created asynchronously via webhook event.
  • Payments automatically captured (so far as for Uruguay, Credit / Debit is auto capture)
  • Customers and Cards automatically saved to Mercado Pago, so you can implement saved cards in the frontend
  • Recurring payments via Mercado Pago Subscriptions (preapproval)

Prerequisites

  • Node.js v20.19 or greater ()
  • A Medusa backend on v2.21.0 or greater
  • For local testing, you need to expose localhost. You can use ngrok
  • Mercado Pago developers setup:
    • Mercadopago developer account
    • Mercado Pago Checkout API application
      • Name your app
      • Choose Pagos Online under "Solution Type"
      • Select Yes to ecommerce platform question and select Otrasplataformas from the dropdown
      • Select CheckoutAPI from the "Product to integrate" dropdown
      • Create application. For more information visit Your Integrations
  • Setup Mercado Pago (credentials)[https://www.mercadopago.com.uy/developers/es/docs/your-integrations/credentials]:
    • Generate test credentials and optionally, production credentials.
  • Setup Mercado Pago webhook notifications
    • Under "Eventos", select Pagos. If you use subscriptions, also select Planes y Suscripciones (topics and )
    • (Optional) Generate a webhook secret. Although it is optional, it is recommended for security purposes.
    • Go to your Medusa backend, run and in a separate terminal . If you are serving the backend in a port other than 9000, change the last argument accordingly.
      • Your localhost will be exposed by a URL like: .
      • Grab the generated URL and go to Mercado Pago webhook configuration. Under "URL para prueba", specify (replacing accordingly):
        • if you only use one-off card payments
        • if you use subscriptions — the subscription provider also handles the one-off topic, so this single URL serves both providers (Mercado Pago only allows one webhook URL per application). These are Medusa's standard webhook routes, which process events asynchronously with built-in delay and retries (configurable via the payment module's / options).
  • A frontend that integrates Payment brick. I suggest you clone this Storefront

How to Install

1. Run the following command in the directory of the Medusa backend using your package manager (for example for npm):

2. Set the following environment variables in :

3. In add the following at the end of the array in your project config object:

4. In add the following to the array in your project config object:

The single entry registers two payment providers that share a common base:

ProviderPayment provider idUse case
Regular paymentsOne-off card payments
Recurring paymentsMercado Pago subscriptions

Both become selectable at checkout — enable whichever you need per region/payment configuration. They share the block above.

Subscriptions (recurring payments)

The provider creates a preapproval (a recurring charge mandate) at checkout, reusing the same Payment Brick card tokenization as one-off payments. Mercado Pago's engine then charges the buyer automatically every cycle — no cron or capture logic needed on your side.

Checkout flow

  1. The storefront initiates a payment session for when the buyer selects the method (no yet — nothing is created at Mercado Pago).
  2. The Payment Brick tokenizes the card. The storefront then re-initiates the session through the standard (), passing the subscription config as the session :

The provider's creates the preapproval with and = payment session id. Re-initiating a session deletes the previous one, which cancels any stale preapproval automatically. 3. The storefront completes the cart as usual ( → ); verifies the preapproval and the Medusa payment is authorized. 4. Mercado Pago creates the first charge asynchronously (it can take minutes to hours). When its webhook reports the charge approved, the Medusa payment flips to captured.

Canceling the Medusa payment cancels the whole subscription at Mercado Pago. See Refunds below.

Events for your subscription engine

Recurring charges beyond the first have no Medusa payment session, so while handling webhooks the provider re-emits every subscription notification on Medusa's event bus. Subscribe from your own subscription module — the plugin is intentionally not coupled to any:

EventEmitted whenPayload
Preapproval created / status change (authorized, paused, cancelled)
A recurring charge (invoice) is created or updated — every cycle, approved or rejected

is the Medusa payment session id used at checkout — correlate it (or , stored in the payment's ) with your own subscription records. Event names and payload types are exported from the package (, , ).

[!NOTE] Delivery is at-least-once: Mercado Pago re-sends webhooks and Medusa's webhook subscriber retries failed events, so the same notification can produce duplicate events. Deduplicate in your subscriber — e.g. key on + for charges, + for subscription updates.

Example subscriber:

Refunds

Use Medusa's standard refund (admin UI or the payment module's ) — the provider maps it to refunding the most recent charged cycle at Mercado Pago (partial amounts supported). Only the checkout cycle has a Medusa payment record, so older cycles are refunded directly at Mercado Pago (dashboard or refunds API) using the from the event.

Testing subscriptions

Subscriptions have stricter test-mode requirements than one-off payments:

  1. In your Mercado Pago application, create two test users (Test accounts section): a seller and a buyer.
  2. Log into the seller test user (use an incognito window), open its own developer panel and use its Access Token as and its Public Key in the storefront.
  3. Configure the webhook (URL + secret) inside the seller test user's application, pointing at your ngrok URL , with the payment + subscription topics enabled. Re-check after every ngrok restart.
  4. must be the buyer test user's email (it must differ from the seller's). Checkout as guest or with a Medusa customer whose email matches the buyer test user.
  5. Use test cards — cardholder name approves, rejects.
  6. After checkout, verify the preapproval in the seller test user's subscriptions panel, and expect the first charge webhook within minutes to a few hours.

Deferred for now (contributions welcome): redirect-based authorization via (subscription without card token), preapproval plans ().


Test the Plugin

1. Run the following command in the directory of the Medusa backend to run the backend:

npm run dev

2. Enable Mercadopago in a region in the admin. Alternatively, you can use the Admin APIs.

3. Place an order using a frontend that collects payment data using Mercadopago Payment brick like this. Send a POST to with a body that adheres to validator


Additional Resources

  • Mercado Pago Online Payments Docs

Еще в этой категории

Посмотреть все
Платежи
Braintree logo

Braintree

От Lambda Curry

Поддержка платежей и 3D Secure через Braintree

Загрузка данных
GitHubnpm
Платежи
Pay. logo

Pay.

От Webbers

Принимайте кредитные карты, цифровые платежи и купи сейчас, плати потом

Загрузка данных
GitHubnpm
Платежи
Mollie logo

Mollie

От Variable Vic

Легко принимайте мультивалютные платежи через Mollie

Загрузка данных
GitHubnpm
npm install @nicogorga/medusa-payment-mercadopago
1# Access Token available in your Mercado Pago application Test Credentials section
2MERCADOPAGO_ACCESS_TOKEN=
3# (Optional) Webhook secret available in your Mercado Pago application Webhooks section
4MERCADOPAGO_WEBHOOK_SECRET=
1projectConfig: {
2 plugins = [
3 // ...
4 {
5 resolve: `@nicogorga/medusa-payment-mercadopago`,
6 options: {},
7 },
8 ];
9}
1modules: [
2 {
3 resolve: '@medusajs/medusa/payment',
4 options: {
5 providers: [
6 {
7 resolve: '@nicogorga/medusa-payment-mercadopago/providers',
8 id: 'mercadopago',
9 options: {
10 accessToken: process.env.MERCADOPAGO_ACCESS_TOKEN,
11 webhookSecret: process.env.MERCADOPAGO_WEBHOOK_SECRET,
12 },
13 dependencies: [
14 ContainerRegistrationKeys.LOGGER,
15 Modules.EVENT_BUS
16 ]
17 }
18 ],
19 }
20 }
21 ],
1await sdk.store.payment.initiatePaymentSession(cart, {
2 provider_id: "pp_mercadopago-subscription_mercadopago",
3 data: {
4 card_token_id: "<Brick formData.token>",
5 payer_email: "buyer@example.com", // optional — falls back to the authenticated customer's email
6 reason: "Monthly box", // optional
7 auto_recurring: {
8 frequency: 1,
9 frequency_type: "months", // or "days"; end_date and free_trial also supported
10 },
11 },
12});
1// src/subscribers/mp-subscription-charge.ts
2import { SubscriberArgs, SubscriberConfig } from "@medusajs/framework";
3import { SubscriptionChargeEventPayload } from "@nicogorga/medusa-payment-mercadopago/types";
4
5export default async function chargeHandler({
6 event: { data },
7}: SubscriberArgs<SubscriptionChargeEventPayload>) {
8 // e.g. create a new order for this cycle, or flag a failed charge
9}
10
11export const config: SubscriberConfig = {
12 event: "mercadopago.subscription.charge.updated",
13};