mollie/mollie-api-php
Official PHP client for the Mollie Payments API. Easily create and manage payments, refunds, customers, subscriptions, and orders from your PHP app with a simple, well-documented wrapper around Mollie’s REST endpoints.
Pros:
HttpClient facade or Guzzle).Mollie_Webhook) can trigger Laravel events (Event::dispatch()) or queue jobs (dispatch()), enabling reactive workflows (e.g., payment confirmation).bind()/singleton()), promoting testability and modularity.Cache facade, logging via Log facade).Cons:
laravel-mollie).AppServiceProvider:
$this->app->singleton(MollieClient::class, function ($app) {
return new \Mollie\Api\Client();
});
Mollie.php) to standardize API calls across the app.Mollie_Webhook::verify()).MollieGatewayException). Custom exceptions should be thrown for consistency.throttle middleware may need customization for API calls.HttpClient as a fallback for non-critical paths.spatie/laravel-activitylog for tracking failures).env() for credentials?unique() validation or Mollie’s idempotency keys)?Log facade or a dedicated service like Sentry)?.env vs. CI/CD (e.g., Laravel Forge/Vapor)?PaymentSucceeded).Mollie_Order->create()).MollieApiKeyMiddleware).HttpClient for consistency.Log facade.Phase 1: Core Integration
composer require mollie/mollie-api-php
.env:
MOLLIE_API_KEY=test_xxx
AppServiceProvider:
$this->app->singleton(MollieClient::class, function ($app) {
return new \Mollie\Api\Client();
});
app/Mollie.php) to wrap common calls:
namespace App\Facades;
use Mollie\Api\Client;
class Mollie extends \Illuminate\Support\Facades\Facade {
protected static function getFacadeAccessor() { return 'mollie'; }
}
Phase 2: Webhooks
routes/web.php:
Route::post('/mollie/webhook', [MollieWebhookController::class, 'handle']);
public function handle(Request $request) {
$event = \Mollie\Api\Types\Event::fromJson($request->getContent());
\Mollie\Api\Webhook::verify($event, $request->header('X-Mollie-Signature'));
// Dispatch Laravel event or queue job
}
Phase 3: Async Operations
CreateMollieOrder):
namespace App\Jobs;
use Mollie\Api\Client;
class CreateMollieOrder implements ShouldQueue {
public function handle(Client $mollie) {
$mollie->orders->create([...]);
}
}
CreateMollieOrder::dispatch($mollie, $orderData);
Phase 4: Observability
Log facade:
Log::info('Mollie API call', ['endpoint' => 'orders', 'data' => $payload]);
mollie/mollie-api-php for updates (e.g., via GitHub releases or Laravel’s composer update).Log or Sentry to catch Mollie API failures.spatie/laravel-circuitbreaker) or fallback to manual processing.README or Swagger docs for Mollie API usage in the codebase.How can I help you explore Laravel packages today?