1. Go to this page and download the library: Download faizpay/php-payment-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use FaizPay\PaymentSDK\Connection;
use FaizPay\PaymentSDK\NotificationHandler;
$connection = Connection::createConnection($terminalId, $terminalSecret);
$notificationHandler = NotificationHandler::createNotificationHandler($connection, $token = $_POST['token']);
// extract the order id
$orderId = $notificationHandler->getOrderID();
// fetch the order from your database
$data = findFromDatabase($orderId);
// if order is not found in system
if (checkIfEntryFound($data)) {
echo "Invalid Token";
die();
}
// validate if the requested payment matches with token
if (!$notificationHandler->validateAmount($data['amount'])) {
echo "Invalid Token";
die();
}
// all checks are passed - update the database to mark payment complete
updateDatabase($orderId, ['completed' => true]);