- How do I install the Mollie API package in Laravel?
- Use Composer to install the package with `composer require mollie/mollie-api-php`. Then, configure the API key in your `.env` file under `MOLLIE_API_KEY`. Bind the client in `AppServiceProvider` using `MollieApiClient::create()` for global access.
- Which Laravel versions are supported by this package?
- The package supports Laravel 8.x and 9.x, as it requires PHP 7.4+. Ensure your Laravel project uses a compatible PHP version (8.0+ recommended) to avoid deprecation issues with cURL or other dependencies.
- Can I use Mollie for recurring payments or subscriptions in Laravel?
- Yes, Mollie supports subscriptions via the API. Use the `createSubscription` method to set up recurring payments. For Laravel, pair this with Laravel’s scheduler to handle renewals, retries, or cancellations via queued jobs or observers.
- How do I handle Mollie webhooks in Laravel securely?
- Use Laravel’s middleware to validate Mollie’s webhook signatures (e.g., `ValidateSignature`). Process webhooks asynchronously with Laravel Queues for scalability. The package provides `WebhookEventMapper` to parse payloads like `payment.authorized` or `subscription.cancelled`.
- What’s the best way to store Mollie payment data in Laravel?
- Store Mollie-specific fields (e.g., `mollie_payment_id`, `status`) in Laravel’s database for reconciliation. Use migrations to add these columns to existing tables. For reporting, create Eloquent models or use Laravel’s query builder to fetch payment data.
- Does Mollie support Apple Pay and Google Pay in Laravel?
- Yes, Mollie’s package supports Apple Pay and Google Pay. Use the `createPayment` method with the `applePay` or `googlePay` payment method. Ensure your Laravel frontend integrates Mollie’s JavaScript SDK for seamless checkout flows.
- How do I mock Mollie API responses for Laravel testing?
- Use Mollie’s test mode (enabled via `testMode: true` in the client config) to simulate payments. For unit tests, mock the `MollieApiClient` using Laravel’s `Mockery` or `PHPUnit` to return fake responses without hitting Mollie’s servers.
- What are the alternatives to Mollie for Laravel payments?
- Alternatives include Stripe (`laravel-cashier`), PayPal (`paypal/checkout-sdk-php`), and Adyen (`adyen/adyen-php-api-library`). Mollie stands out for its European focus, local payment methods (e.g., iDEAL, SEPA), and transparent pricing with no monthly fees.
- How do I handle failed payments or retries in Laravel?
- Mollie returns `pending` or `failed` statuses for payments. Use Laravel’s observers or queued jobs to retry failed payments. For subscriptions, implement a cron job to check for failed renewals and trigger retries via Mollie’s `updateSubscription` method.
- Can I use Mollie with Laravel Cashier for subscriptions?
- No, Mollie’s package is independent of Laravel Cashier. However, you can replicate Cashier’s subscription logic using Mollie’s API directly. For example, create a service to handle subscription lifecycle events (creation, cancellation) via Mollie’s API and Laravel’s queues.