Skip to content

Migration ‐ PaymentMethods

Wouter Jonker edited this page Jan 27, 2026 · 2 revisions

Migration guide – step-by-step - Payment Methods

Preconditions

Install the new PHP SDK via Composer:

composer require paynl/php-sdk

This migration guide is based on the samples available in both the old and the new SDK.

In the old SDK, configuration is loaded via config.php
In the new SDK, configuration is set via the (new) global config/config.global.php


1. Step by Step paymentmethods/getList migration (based on old SDK sample paymentMethods.php)

1.1 Use new request class

Add the following at the top of your script:

use PayNL\Sdk\Model\Request\ServiceGetConfigRequest;

1.2 Use new configRequest class in the top of your try/catch statement. Add your SL-code.

$slCode = 'SL-5261-6001';
$serviceConfig = new ServiceGetConfigRequest($slCode);

1.3 Change the request statement

From

$paymentMethods = \Paynl\Paymentmethods::getList();

Into

$serviceGetConfigResponse = $serviceConfig->start();

1.4 Check your results after retrieving your service location configuration

New:

$paymentMethods = $serviceConfig->getPaymentMethods();
foreach ($paymentMethods as $method) {
    echo $method->getId() . ' - ';
    echo $method->getName() . ' - ';
    echo $method->getImage() . ' - ';
    echo $method->getMinAmount() . ' - ';
    echo $method->getMaxAmount() . ' - ';
    echo $method->getDescription() . ' - ';
    echo $method->hasOptions() ? 'has options' : 'none';
    echo PHP_EOL;
}

1.5 Update exception handling

Note: \Paynl\Error\Error no longer exists in the new SDK.

Old:

    catch (\Paynl\Error\Error $e)

New:

    catch (PayException $e)

(optional)

    catch (\Exception $e)

1.6 Example result

Old

<?php


require_once 'vendor/autoload.php';
require_once 'config.php';

try {
    $paymentMethods = \Paynl\Paymentmethods::getList();
    var_dump($paymentMethods);
} catch (\Paynl\Error\Error $e) {
    echo "ERROR: " . $e->getMessage();
}

New:

<?php

require_once 'vendor/autoload.php';

use PayNL\Sdk\Model\Request\ServiceGetConfigRequest;

try {
    $slCode = 'SL-5261-6001';
    $serviceConfig = new ServiceGetConfigRequest($slCode);

    $serviceGetConfigResponse = $serviceConfig->start();

    $paymentMethods = $serviceGetConfigResponse->getPaymentMethods();
    foreach ($paymentMethods as $method) {
        echo $method->getId() . ' - ';
        echo $method->getName() . ' - ';
        echo $method->getImage() . ' - ';
        echo $method->getMinAmount() . ' - ';
        echo $method->getMaxAmount() . ' - ';
        echo $method->getDescription() . ' - ';
        echo $method->hasOptions() ? 'has options' : 'none';
        echo PHP_EOL;
    }

} catch (\Paynl\Error\Error $e) {
    echo "ERROR: " . $e->getMessage();
}

Clone this wiki locally