Skip to content

Migration ‐ Start payment

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

Migration guide – step-by-step - start payment

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. Start payment migration (based on SDK samples)

1.1 Use new request class

Add the following at the top of your script:

    use PayNL\Sdk\Model\Request\OrderCreateRequest;
    use PayNL\Sdk\Exception\PayException;

1.2 Initialize the request

Add the following statement at the top of the try block:

    $request = new OrderCreateRequest();

1.3 Replace startData with setters on request

The startData array is no longer used and must be replaced by setters on the new request object.

Old:

    $startData['amount'] = 12.50;
    $startData['returnUrl'] = '/return.php';

New:

    $request->setAmount(12.50);
    $request->setReturnurl('/return.php');
    $request->setServiceId('SL-####-####');

1.4 Start the payment

Old:

    $result = \Paynl\Transaction::start($startData);

New:

    $payOrder = $request->start();

1.5 Retrieve redirect URL

Old:

    $result->getRedirectUrl();

New:

    $payOrder->getPaymentUrl();

1.6 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)

Example result

Old

<?php

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

try {
    # Required
    $startData['amount'] = 12.50;
    $startData['returnUrl'] = dirname(\Paynl\Helper::getBaseUrl()) . '/return.php';

    # Optional
    $startData = array_merge($startData, array());

    # Start the transaction
    $result = \Paynl\Transaction::start($startData);

    # Save this transaction ID and link it to your order
    $transactionId = $result->getTransactionId();

    echo '<a href="' . $result->getRedirectUrl() . '">' . $result->getRedirectUrl() . '</a><br>';
    echo $transactionId;

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

New:

<?php

require_once 'vendor/autoload.php';

use PayNL\Sdk\Model\Request\OrderCreateRequest;

try {

    # Create the request
    $request = new OrderCreateRequest();

    $request->setAmount(12.50);
    $request->setServiceId('SL-5261-6001');
    $request->setReturnurl('return.php');

    # Start the transaction
    $payOrder = $request->start();

    # Save this payOrderId and link it to your order
    $payOrderId = $payOrder->getOrderId();

    echo '<a href="' . $payOrder->getPaymentUrl() . '">' . $payOrder->getPaymentUrl() . '</a><br>';
    echo $payOrderId;

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

Clone this wiki locally