- What Laravel versions does mollie/laravel-mollie support, and how do I check compatibility?
- The package typically supports Laravel 10.x and 11.x, but always verify the latest release notes or `composer.json` for exact version requirements. Run `composer show mollie/laravel-mollie` to check installed version compatibility. If using an older Laravel version, check the package’s changelog for deprecated features or manual adjustments needed.
- How do I configure mollie/laravel-mollie for API key and environment-specific settings?
- Add your Mollie API key to `.env` under `MOLLIE_KEY`. The package auto-loads configuration from `config/mollie.php`, which includes environment-specific settings (e.g., test/live mode). Use Laravel’s `config:cache` after changes to apply updates in production. For region-specific endpoints (e.g., EU vs. US), override the `endpoint` in the config file.
- Can I use mollie/laravel-mollie for subscriptions, and how do I handle recurring payments?
- Yes, the package supports Mollie subscriptions via its API wrapper. Use the `createSubscription` method to set up recurring payments, and leverage Laravel’s event system to listen for `mollie.subscription.created` or `mollie.subscription.updated` events. For custom logic (e.g., trial periods, prorations), extend the package’s `Subscription` facade or create a custom service layer.
- How do I handle Mollie webhooks in Laravel, and should I use queues for async processing?
- The package integrates with Laravel’s event system for webhooks. Register a listener for `mollie.webhook.received` in `EventServiceProvider` and process payloads in the handler. For high-volume or time-sensitive workflows, dispatch the event to a queue (e.g., `dispatch(new HandleWebhook($payload))->onQueue('mollie')`). Always validate webhook signatures using Mollie’s `idempotency-key` or `webhook-id` to prevent replay attacks.
- Does mollie/laravel-mollie support Mollie Connect for merchant onboarding, and how do I integrate it with Laravel Socialite?
- Yes, the package includes a Socialite provider for Mollie Connect. Add `MollieConnectProvider::class` to `config/auth.php` under `providers`, then use `Socialite::driver('mollie')->redirect()` to initiate OAuth flows. After authentication, retrieve merchant details via `Socialite::driver('mollie')->user()`. This is ideal for marketplaces or platforms requiring sellers to manage their own Mollie accounts.
- How do I test mollie/laravel-mollie in my Laravel application, including mocking API responses?
- Use Laravel’s HTTP testing helpers to mock Mollie API responses. For example, in a PHPUnit test, stub the `Mollie` facade with `Mollie::shouldReceive('payments.create')->andReturn($mockPayment)`. Test webhooks by dispatching events manually: `event(new MollieWebhookEvent($payload))`. For integration tests, use Mollie’s test mode (configured in `.env`) and verify responses against known test payment IDs.
- What happens if Mollie’s API changes, and how do I handle breaking updates?
- The package abstracts Mollie’s API, but major changes (e.g., endpoint deprecations) may require updates. Monitor the package’s changelog and Mollie’s API documentation for breaking changes. If a feature is missing, extend the package by publishing its config/views or creating a custom facade. For critical dependencies, consider forking the package or submitting PRs to the maintainers.
- Can I use mollie/laravel-mollie alongside other payment processors like Stripe, or is it tightly coupled?
- The package is Laravel-specific but not processor-specific in its architecture. To support multiple processors, abstract payment logic into a service layer (e.g., `PaymentGatewayInterface`) and implement adapters for Mollie and Stripe. Use Laravel’s dependency injection to swap implementations. The package’s facade can be replaced with a custom one if needed for multi-processor setups.
- How do I handle refunds, disputes, or payouts with mollie/laravel-mollie, and are there built-in helpers?
- The package provides methods for refunds (`refunds.create`) and payouts (`payouts.create`), but complex workflows (e.g., partial refunds, dispute resolution) may require custom logic. Track refund statuses via webhooks or poll Mollie’s API periodically. For payouts, use the `payouts` facade methods and validate merchant accounts via Mollie Connect if applicable. Store transaction IDs in your database for reconciliation.
- Are there performance considerations for high-volume payment processing, like rate limiting or retries?
- Mollie’s API has rate limits (e.g., 100 requests/minute for live mode). The package doesn’t enforce retries by default, so implement exponential backoff in your custom logic using Laravel’s `retry` helper or a queue worker. For critical failures, log errors and notify admins via Laravel’s `notify()` system. Monitor API usage with Mollie’s dashboard or integrate their rate-limit headers into your error handling.