Mollie payment driver for LunarPHP v1.x using Mollie SDK v4
composer require noaber/lunar-mollieUse the below command to publish the configuration file to config/lunar/mollie.php.
php artisan vendor:publish --tag=lunar.mollie.configSet the driver in config/lunar/payments.php
<?php
return [
// ...
'types' => [
'paynl' => [
'driver' => 'mollie',
],
],
];Take a look at the configuration in config/lunar/paynl.php.
Where appropriate, edit or set the environment variables in your .env file. At least the keys will need to be set.
MOLLIE_KEY="YOUR_KEY"
MOLLIE_CHECKOUT_SUCCESS="/your-url-to-thank-you-page"You can use the Mollie Test key to switch between live and test mode.
When the user returns form the payment provider webpage, a redirect will be generated, based on the result of the payment. Therefore there have to be four named routed, as defined in the config.
<?php
'payment_paid_route' => 'checkout-success.view',
'payment_canceled_route' => 'checkout-canceled.view',
'payment_open_route' => 'checkout-open.view',
'payment_failed_route' => 'checkout-failure.view',MOLLIE_CHECKOUT_SUCCESS="order-confirmed" #will redirect to url.tld/order-confirmed
MOLLIE_CHECKOUT_CANCELED="your-url-canceled" #will redirect to url.tld/your-url-canceled
MOLLIE_CHECKOUT_OPEN="your-url-open" #will redirect to url.tld/your-url-open
MOLLIE_CHECKOUT_FAILURE="your-url-failure" #will redirect to url.tld/your-url-failureTo start a payment:
<?php
$payment = \Lunar\Facades\Payments::driver('mollie')
->cart($this->cart)
->withData([
'description' => 'Description',
'redirectRoute' => config('lunar.mollie.redirect_route'),
'webhookUrl' => config('lunar.mollie.override_webhook_url') ?: route(config('lunar.mollie.webhook_route')),
'method' => $paymentMethod,
'bank' => $bankID, // optional
'extra1' => '', // optional
'extra2' => '', // optional
'extra3' => '', // optional
])
->initiatePayment();
return redirect($payment->getRedirectUrl());