Integration for Web (SDK)

Prerequisites

Before implementing Mercado Pago Wallet payments, ensure you have:

  1. Enabled Mercado Pago in the DEUNA Admin Panel.
  2. A generated order token.
  3. Integrated the DEUNA Web SDK in your project.
  4. Reviewed the Payment Widget documentation for Web.

Payment Widget Implementation

Display the payment widget by passing the Mercado Pago configuration in the paymentMethods parameter:

DeunaSDK.initPaymentWidget({
  orderToken: 'YOUR_ORDER_TOKEN',
  paymentMethods: [
    {
      paymentMethod: 'wallet',
      processors: ['mercadopago_wallet'],
    },
  ],
  callbacks: {
    onSuccess: async (order) => {
      await DeunaSDK.close();
      // Handle successful payment
      console.log('Payment successful:', order);
    },
    onError: async (error) => {
      // Handle payment errors
      console.error('Payment error:', error);

      if (...) {
        await DeunaSDK.close();
        // Handle UI updates
        console.log('Payment widget closed due to error.');
      }
    },
  },
});