4,000 emails/month for free | Mailtrap sends real emails now!

Laravel Mollie

mollie/laravel-mollie image

Laravel Mollie stats

Downloads
1.6M
Stars
302
Open Issues
2
Forks
54

View on GitHub →

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite

Mollie for Laravel

Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project.

Accepting iDEAL, Apple Pay, Bancontact/Mister Cash, SOFORT Banking, Creditcard, SEPA Bank transfer, SEPA Direct debit, PayPal, Belfius Direct Net, KBC/CBC, paysafecard, ING Home'Pay, Giftcards, Giropay, EPS and Przelewy24 online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.

Looking for a complete recurring billing solution? Take a look at laravel/cashier-mollie instead.

Requirements

  • Get yourself a free Mollie account. No sign up costs.
  • Now you're ready to use the Mollie API client in test mode.
  • Follow a few steps to enable payment methods in live mode, and let us handle the rest.
  • Up-to-date OpenSSL (or other SSL/TLS toolkit)
  • PHP >= 7.0
  • Laravel (or Lumen) >= 5.5
  • Laravel Socialite >= 3.0 (if you intend on using Mollie Connect)

Upgrading from v1.x?

To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the package migration guide.

Not ready to upgrade? The Laravel-Mollie client v1 will remain supported for now.

Fresh install? Continue with the installation guide below.

Installation

Add Laravel-Mollie to your composer file via the composer require command:

composer require mollie/laravel-mollie

Or add it to composer.json manually:

"require": {
"mollie/laravel-mollie": "^2.0"
}

Laravel-Mollie's service providers will be automatically registered using Laravel's auto-discovery feature.

Note: For Lumen you have to add the Mollie facade and service provider manually to: bootstrap/app.php :

$app->withFacades(true, ['Mollie\Laravel\Facades\Mollie' => 'Mollie']);
 
$app->register(Mollie\Laravel\MollieServiceProvider::class);

Configuration

You'll only need to add the MOLLIE_KEY variable to your .env file.

MOLLIE_KEY=test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Example usage

Here you can see an example of just how simple this package is to use.

A payment using the Mollie API

use Mollie\Laravel\Facades\Mollie;
 
public function preparePayment()
{
$payment = Mollie::api()->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "10.00" // You must send the correct number of decimals, thus we enforce the use of strings
],
"description" => "Order #12345",
"redirectUrl" => route('order.success'),
"webhookUrl" => route('webhooks.mollie'),
"metadata" => [
"order_id" => "12345",
],
]);
 
// redirect customer to Mollie checkout page
return redirect($payment->getCheckoutUrl(), 303);
}
 
/**
* After the customer has completed the transaction,
* you can fetch, check and process the payment.
* This logic typically goes into the controller handling the inbound webhook request.
* See the webhook docs in /docs and on mollie.com for more information.
*/
public function handleWebhookNotification(Request $request) {
$paymentId = $request->input('id');
$payment = Mollie::api()->payments->get($paymentId);
 
if ($payment->isPaid())
{
echo 'Payment received.';
// Do your thing ...
}
}

Global helper method

For your convencience we've added the global mollie() helper function. It's an easy shortcut to the Mollie::api() facade accessor.

// Using facade accessor
$payment = \Mollie\Laravel\Facades\Mollie::api()->payments->get($payment_id);
 
// Using global helper function
$payment = mollie()->payments->get($payment_id);

Other examples

Roadmap

You can find the latest development roadmap for this package here. Feel free to open an issue if you have a feature request.

Want to help us make our Laravel module even better?

Want to help us make our Laravel module even better? We take pull requests, sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. Check out our vacancies or get in touch.

License

BSD (Berkeley Software Distribution) License. Copyright (c) 2016, Mollie B.V.

Support

Contact: www.mollie.cominfo@mollie.com — +31 20-612 88 55

mollie photo

Making payments better.


Mollie Laravel Mollie Related Articles

Laravel Cashier Mollie V1 Is Now Available image

Laravel Cashier Mollie V1 Is Now Available

Read article
Subscription billing with Laravel Cashier for Mollie image

Subscription billing with Laravel Cashier for Mollie

Read article
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud