A secure, customizable React component for integrating the Mercado Pago payment gateway into Next.js applications. It provides a multi-step flow including product selection, order confirmation, and checkout via Mercado Pago's Payment Brick.
- Multi-Step Flow: Guided experience from product selection to payment completion
- Secure Payment Processing: Server-side validation with CSRF protection
- Mercado Pago Integration: Seamless integration with Payment Brick
- Responsive Design: Mobile-optimized checkout experience
- Configurable Redirects: Custom success, pending, and failure pages
- Enhanced Logging: Development-only logging with sensitive data protection
- Framer Integration: Easily embed as an iframe in Framer sites
- Vercel Ready: Optimized for deployment on Vercel
- Install dependencies:
npm install @mercadopago/sdk-react clsx tailwind-merge
- Configure environment variables:
NEXT_PUBLIC_MERCADOPAGO_PUBLIC_KEY=your_public_key MERCADOPAGO_ACCESS_TOKEN=your_access_token NEXT_PUBLIC_HOST_URL=https://your-deployment-url.com
- Import and use the component:
import PaymentFlow from '../components/PaymentFlow'; export default function Checkout() { return ( <PaymentFlow apiBaseUrl={process.env.NEXT_PUBLIC_HOST_URL} mercadoPagoPublicKey={process.env.NEXT_PUBLIC_MERCADOPAGO_PUBLIC_KEY} successUrl="/success" pendingUrl="/pending" failureUrl="/failure" /> ); }
For comprehensive documentation including:
- Complete API reference
- Security considerations
- Customization options
- Troubleshooting guide
- Logging system
Please see the DOCUMENTATION.md file.
This component implements several security best practices:
- CSRF protection
- Input sanitization
- Server-side price validation
- Secure environment variable handling
- Content Security Policy headers
Released under the MIT License.