-
Notifications
You must be signed in to change notification settings - Fork 4
Migration ‐ Start payment
Wouter Jonker edited this page Jan 27, 2026
·
2 revisions
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
Add the following at the top of your script:
use PayNL\Sdk\Model\Request\OrderCreateRequest;
use PayNL\Sdk\Exception\PayException;Add the following statement at the top of the try block:
$request = new OrderCreateRequest();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-####-####');Old:
$result = \Paynl\Transaction::start($startData);New:
$payOrder = $request->start();Old:
$result->getRedirectUrl();New:
$payOrder->getPaymentUrl();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)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();
}