npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

expo-mercadopago-integration

v1.0.2

Published

Expo library for integrating Mercado Pago native SDK without ejecting

Downloads

12

Readme

Expo Mercado Pago SDK

Una librería npm para integrar el SDK nativo de Mercado Pago en aplicaciones Expo sin necesidad de ejectar.

🚀 Características

  • ✅ Integración completa con el SDK nativo de Mercado Pago
  • ✅ Soporte para iOS y Android
  • ✅ No requiere ejectar de Expo
  • ✅ TypeScript support
  • ✅ Manejo de eventos de pago
  • ✅ Verificación de app instalada
  • ✅ Configuración automática de permisos

📦 Instalación

npm install expo-mercadopago-sdk

🔧 Configuración

1. Configurar el plugin en app.json

{
  "expo": {
    "plugins": [
      [
        "./node_modules/expo-mercadopago-sdk/plugin.js",
        {
          "publicKey": "TEST-12345678-1234-1234-1234-123456789012"
        }
      ]
    ]
  }
}

2. Configurar las credenciales

Obtén tu public_key desde el panel de desarrolladores de Mercado Pago.

📖 Uso

Inicialización básica

import { createMercadoPagoSDK, MercadoPagoConfig } from 'expo-mercadopago-sdk';

const config: MercadoPagoConfig = {
  publicKey: 'TEST-12345678-1234-1234-1234-123456789012',
  siteId: 'MLA', // Argentina
  language: 'es',
};

const mercadopago = createMercadoPagoSDK(config);
await mercadopago.initialize();

Iniciar un pago

// Opción 1: Usando preference ID
const result = await mercadopago.startPayment('123456789-12345678-12345678-12345678');

// Opción 2: Configurando preference ID en la configuración
const config: MercadoPagoConfig = {
  publicKey: 'TEST-12345678-1234-1234-1234-123456789012',
  preferenceId: '123456789-12345678-12345678-12345678',
};

const mercadopago = createMercadoPagoSDK(config);
await mercadopago.initialize();
const result = await mercadopago.startPayment();

Escuchar eventos de pago

const subscription = mercadopago.addPaymentResultListener((result) => {
  switch (result.status) {
    case 'approved':
      console.log('Pago aprobado:', result.paymentId);
      break;
    case 'rejected':
      console.log('Pago rechazado:', result.statusDetail);
      break;
    case 'pending':
      console.log('Pago pendiente');
      break;
    case 'in_process':
      console.log('Pago en proceso');
      break;
  }
});

// Limpiar listener cuando no se necesite
mercadopago.removePaymentResultListener(subscription);

Verificar si Mercado Pago está instalado

const isInstalled = await mercadopago.isMercadoPagoInstalled();
console.log('Mercado Pago instalado:', isInstalled);

Obtener versión del SDK

const version = await mercadopago.getSDKVersion();
console.log('Versión del SDK:', version);

🏗️ Estructura del proyecto

expo-mercadopago-sdk/
├── src/
│   └── ExpoMercadoPagoModule.ts    # Interfaz TypeScript
├── ios/
│   ├── ExpoMercadoPagoModule.swift # Módulo nativo iOS
│   └── ExpoMercadoPagoModule.podspec
├── android/
│   ├── build.gradle
│   └── src/main/java/expo/modules/mercadopago/
│       └── ExpoMercadoPagoModule.kt # Módulo nativo Android
├── plugin.js                       # Plugin de configuración Expo
├── example/
│   └── App.tsx                     # Ejemplo de uso
├── package.json
└── README.md

🔌 API Reference

MercadoPagoConfig

interface MercadoPagoConfig {
  publicKey: string;        // Tu public key de Mercado Pago
  preferenceId?: string;    // ID de preferencia (opcional)
  siteId?: string;         // ID del sitio (ej: 'MLA' para Argentina)
  language?: string;       // Idioma (ej: 'es', 'en')
}

PaymentResult

interface PaymentResult {
  status: 'approved' | 'rejected' | 'pending' | 'in_process';
  paymentId: string;
  statusDetail: string;
  paymentData?: PaymentData;
  error?: {
    message: string;
    code: string;
  };
}

Métodos disponibles

  • initialize(): Inicializa el SDK
  • startPayment(preferenceId?): Inicia el flujo de pago
  • addPaymentResultListener(callback): Agrega listener para eventos de pago
  • removePaymentResultListener(subscription): Remueve listener
  • isMercadoPagoInstalled(): Verifica si la app está instalada
  • getSDKVersion(): Obtiene la versión del SDK

🛠️ Desarrollo

Prerrequisitos

  • Node.js 16+
  • Expo CLI
  • Xcode (para iOS)
  • Android Studio (para Android)

Instalación de dependencias

npm install

Build

npm run build

Limpiar

npm run clean

Nota sobre dependencias

Esta librería utiliza expo-modules-core como dependencia principal. Si encuentras errores de instalación, asegúrate de tener una versión compatible de Expo en tu proyecto.

📱 Ejemplo completo

Ver el archivo example/App.tsx para un ejemplo completo de implementación.

🔒 Permisos

La librería automáticamente configura los siguientes permisos:

Android:

  • android.permission.INTERNET
  • android.permission.ACCESS_NETWORK_STATE

iOS:

  • URL schemes para Mercado Pago

🐛 Troubleshooting

Error: "Module not found"

Asegúrate de que el plugin esté configurado correctamente en app.json.

Error: "Public key required"

Verifica que estés usando una public key válida de Mercado Pago.

Error: "Preference ID required"

Asegúrate de proporcionar un preference ID válido antes de iniciar el pago.

📄 Licencia

MIT

🤝 Contribuir

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add some AmazingFeature')
  4. Push a la rama (git push origin feature/AmazingFeature)
  5. Abre un Pull Request

📞 Soporte

Si tienes problemas o preguntas, abre un issue en GitHub.

🔗 Enlaces útiles