Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mollie Api Php Laravel Package

mollie/mollie-api-php

Official Mollie API client for PHP. Create and manage payments, orders, customers, subscriptions, refunds, and settlements. Supports iDEAL, card, PayPal, Apple Pay, Google Pay, Bancontact, SEPA and more. Includes webhooks and OAuth support.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel Compatibility: The package is PHP-based and leverages Composer, making it natively compatible with Laravel’s dependency management and autoloading systems. Laravel’s service container can easily instantiate the \Mollie\Api\MollieApiClient and bind it as a singleton or context-bound service.
  • Domain Alignment: Mollie’s API aligns well with Laravel’s e-commerce and payment workflows (e.g., Laravel Cashier, Breeze, or custom checkout flows). The package supports webhooks, recurring payments, and multi-currency transactions, which are critical for financial systems.
  • Event-Driven Architecture: Mollie’s webhook system integrates seamlessly with Laravel’s event/queue system (e.g., queue:listen for processing webhook payloads asynchronously). The package includes built-in signature validation for security.
  • Testing Support: The package provides mocking utilities (e.g., MockEvent, fake retain requests) and test-mode APIs, which align with Laravel’s testing tools (Pest, PHPUnit) and factories.

Integration Feasibility

  • Low Friction: The package abstracts Mollie’s REST API into request/response objects (e.g., CreatePaymentRequest, Payment resource), reducing boilerplate for HTTP clients, serialization, and error handling.
  • Laravel-Specific Enhancements:
    • Service Provider: Can be bootstrapped in AppServiceProvider to configure the client globally (e.g., API keys from .env).
    • Middleware: Webhook routes can use Laravel’s middleware (e.g., ValidateSignature) for security.
    • Queues: Webhook processing can be offloaded to Laravel Queues for scalability.
    • Validation: Laravel’s Form Request validation can validate payment inputs before creating requests.
  • Database Integration: Payment data (e.g., id, status, amount) can be stored in Laravel’s database for reconciliation or reporting.

Technical Risk

Risk Area Mitigation Strategy
API Key Management Store API keys in Laravel’s .env and use environment variables or Vault (e.g., Laravel Forge, HashiCorp Vault). Rotate keys via Mollie’s dashboard.
Webhook Reliability Implement retry logic (exponential backoff) for failed webhook deliveries. Use Laravel’s queue:failed table to monitor and reprocess failed jobs.
Idempotency Mollie supports idempotency keys; ensure Laravel’s HTTP client (Guzzle) respects these headers.
Currency/Regional Limits Validate supported currencies/countries in Laravel’s validation rules (e.g., rule:in:EUR,USD). Mollie’s API will reject unsupported methods, but pre-validation reduces noise.
Rate Limiting Mollie’s API has rate limits. Cache responses (e.g., Illuminate\Support\Facades\Cache) for frequent queries (e.g., payment status checks).
PHP Version Compatibility The package supports PHP 7.4+, which aligns with Laravel’s LTS support (8.0+). Test with Laravel’s latest PHP version to catch deprecations (e.g., cURL changes in PHP 8.5).
Webhook Security Use Laravel’s signed routes or middleware to validate Mollie’s webhook signatures. The package provides WebhookEventMapper for parsing payloads.
Data Migration If migrating from another payment provider, use Laravel’s migrations to add Mollie-specific fields (e.g., mollie_payment_id, mollie_webhook_signature) to existing tables.

Key Questions

  1. Payment Flow Complexity:

    • Will the application use one-time payments, subscriptions, or recurring mandates? Mollie’s package supports all, but subscriptions require additional Laravel logic (e.g., scheduling jobs for renewals).
    • Example: Use Laravel’s scheduler to check for failed subscriptions and trigger retries.
  2. Webhook Handling:

    • How will webhooks be processed? Synchronously (routes) or asynchronously (queues)? Laravel’s queue:listen is recommended for scalability.
    • Example: Create a MollieWebhookHandler service to process events like payment.authorized or subscription.cancelled.
  3. Error Recovery:

    • How will failed payments/subscriptions be handled? Mollie’s API returns pending or failed statuses; Laravel can use observers or queued jobs to retry or notify users.
    • Example: Log failed payments to laravel.log and send emails via Laravel Notifications.
  4. Testing Strategy:

    • Will tests use Mollie’s test mode or a mock client? The package provides MockEvent for unit tests; integration tests should use test API keys.
    • Example: Use Pest’s mock() to simulate webhook payloads in feature tests.
  5. Multi-Tenant Support:

    • If the app is multi-tenant, will each tenant have a dedicated Mollie account? Laravel’s context binding (e.g., tenant()->mollieClient) can manage per-tenant API keys.
  6. Compliance:

    • Does the application need to comply with PCI DSS or GDPR? Mollie is PCI-compliant, but Laravel’s logging and data storage must also adhere to regulations (e.g., encrypting payment metadata).

Integration Approach

Stack Fit

Laravel Component Mollie Package Integration
Service Container Bind MollieApiClient as a singleton in AppServiceProvider with API keys from .env.
HTTP Client Use Laravel’s Guzzle HTTP client (default) or configure custom adapters (e.g., Mollie\Api\Http\Adapter\GuzzleAdapter).
Validation Validate payment inputs using Laravel’s Form Requests (e.g., CreatePaymentRequest). Example: Ensure amount is numeric and currency is supported.
Routing Create routes for webhooks (e.g., POST /mollie/webhook) and payment redirects (e.g., GET /payment/{id}/redirect). Use middleware to validate signatures.
Queues Process webhooks asynchronously with Laravel Queues. Example: Dispatch a HandleMollieWebhook job when a webhook is received.
Events Dispatch Laravel events (e.g., PaymentAuthorized) when Mollie webhooks trigger actions. Listen to these events in services or notifications.
Database Store Mollie payment IDs and metadata in Laravel tables. Example: Add mollie_payment_id to orders table for reconciliation.
Testing Use Mollie’s test mode and Laravel’s Pest/PHPUnit to mock API responses. Example: Stub MollieApiClient to return fake payments in unit tests.
Logging Log Mollie API responses/errors to laravel.log using Laravel’s Log facade. Example: Log failed payment attempts with Log::error($payment->failureMessage).
Notifications Send user notifications (e.g., payment failed) using Laravel Notifications (e.g., Mail, Slack). Example: Trigger PaymentFailedNotification when a webhook reports payment.failed.

Migration Path

  1. Phase 1: Setup and Configuration

    • Install the package: composer require mollie/mollie-api-php.
    • Configure API keys in .env:
      MOLLIE_API_KEY=test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM
      MOLLIE_WEBHOOK_SECRET=whsec_test_...
      
    • Bind the client in AppServiceProvider:
      $this->app->singleton(MollieApiClient::class, function ($app) {
          $client = new MollieApiClient();
          $client->setToken(config('services.mollie.api_key'));
          return $client;
      });
      
  2. Phase 2: Core Payment Integration

    • Implement a PaymentService to handle creation/refunds:
      use Mollie\Api\Http\Requests\CreatePaymentRequest;
      use Mollie\Api\Http\Data\Money;
      
      class PaymentService {
          public function createPayment(float $amount, string $currency, string $description) {
              $payment = $this->mollieClient->send(new CreatePaymentRequest(
                  description: $description,
                  amount: new Money($currency, $amount),
                  redirectUrl: route('payment.redirect'),
                  webhookUrl: route
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor