noaber/lunar-paynl

Pay.nl payment driver for LunarPHP.

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/noaber/lunar-paynl

v1.0.1 2025-11-12 19:06 UTC

This package is auto-updated.

Last update: 2025-11-12 19:07:57 UTC


README

Pay.nl payment driver for LunarPHP v1.x

Installation

Require the composer package

composer require noaber/lunar-paynl

Publish the Pay.nl configuration

Use the below command to publish the configuration file to config/lunar/paynl.php.

php artisan vendor:publish --tag=lunar.paynl.config

Enable the payment driver

Set the driver in config/lunar/payments.php

<?php

return [
    // ...
    'types' => [
        'paynl' => [
            'driver' => 'paynl',
        ],
    ],
];

Add your Paynl credentials and other config

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.

create named routes for success and cancellation pages

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',

or create urls using the .env variables (eg: when using a headless CMS and custom urls)

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-failure

Example

To 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

Thanks to: https://github.com/lobbesnl/lunar-paynl for the initial package for LunarPHP v0.x