PHP code example of tcgunel / omnipay-paynkolay
1. Go to this page and download the library: Download tcgunel/omnipay-paynkolay 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/ */
tcgunel / omnipay-paynkolay example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('PayNKolay');
$gateway->setSxToken('your-sx-token-here');
$gateway->setSxListToken('your-sx-list-token-here');
$gateway->setSxCancelToken('your-sx-cancel-token-here');
$gateway->setMerchantSecretKey('your-merchant-secret-key-here');
$gateway->setTestMode(true); // sandbox base URL
$response = $gateway->purchase([
'amount' => '100.00',
'transactionId' => 'ORDER-123', // becomes Paynkolay `clientRefCode`
'installment' => 1,
'card' => [
'firstName' => 'Ada',
'lastName' => 'Lovelace',
'number' => '4155650100416111',
'expiryMonth' => '01',
'expiryYear' => '2030',
'cvv' => '123',
'email' => '[email protected] ',
'billingPhone' => '5550000000',
'billingAddress1' => 'Address line 1',
],
'clientIp' => '127.0.0.1',
// optional buyer metadata — passed through when supplied:
'tckn' => '12345678901',
'description' => 'Order #123',
'merchantCustomerNo' => 'M-9999',
])->send();
if ($response->isSuccessful()) {
echo $response->getTransactionReference(); // REFERENCE_CODE
} else {
echo $response->getMessage();
}
$response = $gateway->purchase([
'amount' => '100.00',
'transactionId' => 'ORDER-123',
'installment' => 1,
'secure' => true,
'returnUrl' => 'https://merchant.example/orders/ORDER-123/verify-payment',
'cancelUrl' => 'https://merchant.example/orders/ORDER-123/payment-failed',
'card' => [ /* ... */ ],
'clientIp' => '127.0.0.1',
])->send();
if ($response->isRedirect()) {
// Paynkolay returns the bank's 3D Secure HTML inline as
// BANK_REQUEST_MESSAGE (escaped). Decoded HTML is ready to emit:
echo $response->getRedirectHtml();
}
$notification = $gateway->acceptNotification($_POST);
if (! $notification->verifyHash($merchantSecretKey)) {
return failure_view('3DS hash verification failed');
}
if (! $notification->isSuccessful()) {
return failure_view($notification->getMessage());
}
// 3DS challenge succeeded and the postback is authentic — finalize:
$completion = $gateway->completePurchase([
'referenceCode' => $notification->getTransactionReference(),
])->send();
if ($completion->isSuccessful()) {
// Charge captured.
} else {
echo $completion->getMessage();
}
$gateway->cancel([
'referenceCode' => 'IKSIRPF450511',
'amount' => '100.00',
'trxDate' => '2026-01-15', // accepts any parseable form; serialised as YYYY.MM.DD
])->send();
$gateway->refund([
'referenceCode' => 'IKSIRPF450511',
'amount' => '50.00',
'trxDate' => '2026.01.15', // original payment date
])->send();
$response = $gateway->paymentList([
'startDate' => '01.01.2026',
'endDate' => '31.01.2026',
'clientRefCode' => 'ORDER-123', // optional filter
])->send();
if ($response->isSuccessful()) {
foreach ($response->getTransactions() as $transaction) {
// …
}
// Or look up a single transaction by our-side reference code:
$found = $response->findByClientReferenceCode('ORDER-123');
}
$response = $gateway->payByLink([
'amount' => '100.00',
'transactionId' => 'ORDER-123',
'installment' => 1,
'returnUrl' => 'https://merchant.example/orders/ORDER-123/success',
'cancelUrl' => 'https://merchant.example/orders/ORDER-123/fail',
'clientIp' => '127.0.0.1',
])->send();
if ($response->isRedirect()) {
header('Location: ' . $response->getRedirectUrl());
exit;
}
$gateway->payByLinkSend([
'amount' => '250.00',
'transactionId' => 'ORDER-456',
'fullName' => 'Customer Name',
'gsm' => '5550000000',
'linkExpirationTime' => '2026-12-30',
'description' => 'Invoice payment',
'sendSms' => true,
'sendEmail' => true,
'card' => ['email' => '[email protected] '], // EMAIL is
$gateway->payByLinkDelete([
'linkRef' => 'by6353337820250825153001', // the `q` value from the link URL
])->send();
$response = $gateway->binInstallment([
'binNumber' => '415565',
'amount' => '100.00',
])->send();
if ($response->isSuccessful()) {
print_r($response->getInstallments());
}
$response = $gateway->merchantInfo()->send();
if ($response->isSuccessful()) {
print_r($response->getCommissionList());
}