Pay.nl payment driver for LunarPHP v1.x
composer require noaber/lunar-paynlUse the below command to publish the configuration file to config/lunar/paynl.php.
php artisan vendor:publish --tag=lunar.paynl.configSet the driver in config/lunar/payments.php
<?php
return [
// ...
'types' => [
'paynl' => [
'driver' => 'paynl',
],
],
];Take a look at the configuration in config/paynl.php.
Where appropriate, edit or set the environment variables in your .env file. At least the keys will need to be set.
PAYNL_TEST_MODE=true
PAYNL_TOKEN_CODE=
PAYNL_TOKEN_CODE_TEST=
PAYNL_API_TOKEN=
PAYNL_API_TOKEN_TEST=
PAYNL_SERVICE_ID=
PAYNL_SERVICE_ID_TEST=You can use the PAYNL_TEST_MODE environment variable 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',PAYNL_CHECKOUT_SUCCESS="order-confirmed" #will redirect to url.tld/order-confirmed
PAYNL_CHECKOUT_CANCELED="your-url-canceled" #will redirect to url.tld/your-url-canceled
PAYNL_CHECKOUT_OPEN="your-url-open" #will redirect to url.tld/your-url-open
PAYNL_CHECKOUT_FAILURE="your-url-failure" #will redirect to url.tld/your-url-failureTo start a payment:
<?php
$payment = \Lunar\Facades\Payments::driver('paynl')
->cart($this->cart)
->withData([
'description' => 'Description',
'redirectRoute' => config('lunar.paynl.redirect_route'),
'webhookUrl' => config('lunar.paynl.override_webhook_url') ?: route(config('lunar.paynl.webhook_route')),
'method' => $paymentMethod,
'bank' => $bankID, // optional
'extra1' => '', // optional
'extra2' => '', // optional
'extra3' => '', // optional
])
->initiatePayment();
return redirect($payment->getRedirectUrl());Thanks to: https://github.com/lobbesnl/lunar-paynl for the initial package for LunarPHP v0.x