Git Product home page Git Product logo

medusa-payment-mercadopago's Introduction

medusaimage

medusa-payment-mercadopago

This is a Medusa plugin that adds Mercado Pago as a payment provider to Medusa ecommerce stores.

The plugin provides a seamless integration between Mercado Pago and MedusaJS, enabling online merchants to easily accept payments from customers in their local currency. The repository includes documentation on how to install and configure the plugin, as well as examples of its usage.

Installation

In the root of your Medusa server, run the following command to install the plugin:

npm install @minskylab/medusa-payment-mercadopago

or

yarn add @minskylab/medusa-payment-mercadopago

Configuration

Register for a MercadoPago account and get your credentials. To configure the plugin, you'll need to set the following environment variables in your environment file (.env)

MERCADOPAGO_ACCESS_TOKEN=<your access token>
MERCADOPAGO_SUCCESS_BACKURL=<your backurl when payment is successful>
MERCADOPAGO_WEBHOOK_URL=<your medusa server url>

Next, in medusa-config.js add the following at the end of the plugins array:

const plugins = [
  // other plugins
  {
    resolve: `@minskylab/medusa-payment-mercadopago`,
    options: {
      access_token: process.env.MERCADOPAGO_ACCESS_TOKEN,
      success_backurl: process.env.MERCADOPAGO_SUCCESS_BACKURL,
      webhook_url: process.env.MERCADOPAGO_WEBHOOK_URL,
    },
  },
];

Client side configuration

medusa-payment-mercadopago returns a preference id you should send to Mercadopago Checkout as the preference id.

By using the returned ID, the plugin can obtain the necessary URL to initiate the payment flow with the product information.

Using Preference ID

medusa-payment-mercadopago inserts a preferenceId into the PaymentSession's data.

Provide this id to initialize your checkout.

Add Mercadopago Checkout Pro

To add Checkout Pro to your client-side, you'll need to install the Mercado Pago frontend SDK. In this example, we'll be using the react-sdk-mercadopago package to integrate the SDK with React.

Once you've installed the SDK, you can initialize the checkout by providing your PUBLIC KEY and the preferenceId. Take a look at the example below for guidance.

In this example, we've used a button to open Checkout Pro in a modal format, allowing the user to complete their purchase.

import { useMercadopago } from "react-sdk-mercadopago";

const MERCADOPAGO_PUBLIC_KEY = process.env.NEXT_PUBLIC_MERCADOPAGO_PUBLIC_KEY || "";

const MercadoPagoButton = ({ session }: { session: PaymentSession }) => {
  const mercadoPago = useMercadopago.v2(MERCADOPAGO_PUBLIC_KEY, {
    locale: "es-PE",
  });

  const checkout = mercadoPago?.checkout({
    preference: {
      id: session.data.preferenceId, //preference ID
    },
  });

  return (
    <Button
      size="md"
      onClick={() => checkout.open()}
    >
      Pagar
    </Button>
  );
};

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue if you encounter any problems.

License

This project is licensed under the MIT License

medusa-payment-mercadopago's People

Contributors

annalbirena avatar bregydoc avatar eltruforce avatar marcotuliocnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

medusa-payment-mercadopago's Issues

help to integrate mercadopago plugin

hello i am trying to integrate the mercado pago plugin to the storefront but i have problems to get the checkout button, when i press the mercado pago option nothing happens and i get the following error

image

if someone could help me I would be very grateful because this is the only payment method for latin america.

Checkout transparent

Does this module support transparent checkout? In this case, can the customer enter their card details directly on the StoreFront screen?

Una de las partes con la que intentas hacer el pago es de prueba.

Hola! Al tratar de realizar un pago con un usuario de prueba recibo el mensaje del asunto. Probé con la Public Key y Access Token del usuario de prueba Vendedor y pasa lo mismo.

También probé con la SDK @mercadopago/sdk-react y tuve problemas para completar el pago, recibiendo un error genérico.

Cual es el estado del plugin? Sigue funcionando en la última versión de Medusa?

Error 500 al eliminar producto del carro

Al eliminar un producto del carro se lanza la excepción "Method not implemented." en el método deletePayment. Comenté la línea y lo puedo eliminar correctamente.

Cual es el fin de este método? hacer un rollback del pago?
Entiendo que si se realiza el pago luego se debería limpiar el carro.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.