Overview
Laravel MercadoPago is a comprehensive integration package that simplifies working with Mercado Pago payment services in Laravel applications. Built with modern PHP practices and Laravel’s service container architecture, it provides a clean, testable interface to the Mercado Pago SDK.What It Solves
This package handles the complexity of Mercado Pago integration by:- Credential Management - Resolves credentials from configuration and environment variables automatically
- SDK Configuration - Configures the Mercado Pago SDK with access tokens and runtime environment settings
- Service Layer - Provides injectable services for all major Mercado Pago operations
- Webhook Security - Registers a webhook endpoint with HMAC signature validation when a secret is configured
- Development Support - Exposes demo routes for local testing and development
The package focuses on encapsulating communication with the Mercado Pago SDK and exposing a reusable API foundation. It does not include migrations, Blade views, frontend components, payment persistence, or pre-configured queues.
Key Features
Comprehensive Service Coverage
The package includes dedicated services for all major Mercado Pago operations:- PreferenceService - Create and manage payment preferences for Checkout Pro
- PaymentService - Process and query payments
- RefundService - Handle full and partial refunds
- CustomerService - Manage customer records
- CardService - Store and manage customer cards
- PaymentMethodService - Query available payment methods
- TestUserService - Generate test users for QA environments
- WebhookService - Receive and validate Mercado Pago notifications
Auto-Discovery Support
The package leverages Laravel’s package auto-discovery feature, automatically registering:Flexible Route Configuration
- Always Active: Production webhook endpoint at
/api/mercadopago/webhooks - Demo Routes: Development and testing endpoints (enabled only in
localandtestingenvironments) - Customizable Prefix: Configure route prefixes via environment variables
Security First
- HMAC signature validation for webhook authenticity
- Environment-based credential resolution
- Demo route protection (disabled in production)
- Configurable runtime environments
Requirements
Laravel 12
Compatible with Laravel 12 framework components:
illuminate/contracts ^12.0illuminate/http ^12.0illuminate/routing ^12.0illuminate/support ^12.0
What’s NOT Included
To maintain focus and flexibility, this package intentionally excludes:- Database migrations - Payment persistence logic belongs in your application
- Blade views - Frontend integration is project-specific
- UI components - JavaScript widgets and checkout forms are implemented separately
- Job queues - Queue configuration depends on your architecture
- Business logic - Authentication, authorization, and domain rules stay in your app
Architecture Philosophy
Laravel MercadoPago follows a service-oriented architecture:- Services encapsulate SDK calls - Each service wraps specific Mercado Pago API functionality
- Dependency injection ready - All services are registered as singletons in the container
- Controller-agnostic - Use the services in controllers, actions, jobs, or commands
- Testable - Services can be mocked and tested independently
Recommended Implementation Pattern
Next Steps
Installation
Install the package via Composer and configure auto-discovery
Configuration
Set up environment variables and publish configuration files