-
Notifications
You must be signed in to change notification settings - Fork 1
Exchange
Wouter Jonker edited this page Jan 31, 2025
·
2 revisions
The SDK includes functionality to make it very easy to setup your exchange handler, and process your orders.
<?php
# Include your autoload.php
require '../vendor/autoload.php';
use PayNL\Sdk\Util\Exchange;
use Throwable;
# Instantiate exchange object
$exchange = new Exchange();
try {
# Process the exchange request. This will take care of any type of exchange: GET, POST and even requests.
# This function will return a payOrder object or throws an exception when something went wrong.
$payOrder = $exchange->process();
if ($payOrder->isPending()) {
$responseResult = yourCodeToProcessPendingOrder($payOrder->getReference());
$responseMessage = 'Processed pending';
} elseif ($payOrder->isPaid()) {
$responseResult = yourCodeToProcessPaidOrder($payOrder->getReference());
$responseMessage = 'Processed paid. Order: ' . $payOrder->getReference();
} else {
$responseResult = true;
$responseMessage = 'No action defined for payment state ' . $payOrder->getStateId();
}
} catch (Throwable $exception) {
$responseResult = false;
$responseMessage = $exception->getMessage();
}
# Finally respond to Pay. by using setResponse:
$exchange->setResponse($responseResult, $responseMessage);
See also the sample in the repository.
Function | Description |
---|---|
isPaid | To check whether the payment was fully paid |
isFastCheckout | To determine whether the transaction is a fastCheckout-transaction |
getReference | To retrieve your payment reference |