1. Go to this page and download the library: Download pongsit/scb 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/ */
pongsit / scb example snippets
use Pongsit\Scb\Config;
$config = Config::fromArray([
'clientId' => '...',
'clientSecret' => '...',
'merchantId' => '...', // biller id
'ppId' => '...', // PromptPay id on the QR
'ref3' => 'RAB', // as registered with SCB
'env' => 'sandbox', // sandbox | uat | production
]);
use Pongsit\Scb\{Client, Qr};
$qr = new Qr(new Client($config));
$result = $qr->create(
365.00, // amount due
'AJNUNU', // ref1 — appears on the payer's slip
(string) $orderId // ref2 — comes back in the webhook, must identify your row
);
echo '<img src="' . Qr::dataUri($result['qrImage']) . '">';
use Pongsit\Scb\{SettlementStore, Transaction};
class OrderStore implements SettlementStore
{
public function expectedAmount($ref2)
{
$row = /* SELECT price FROM orders WHERE id = $ref2 */;
return $row ? (float) $row['price'] : null; // null = I don't know this reference
}
public function isSettled($ref2)
{
return /* SELECT confirm FROM orders WHERE id = $ref2 */;
}
public function settle($ref2, Transaction $transaction)
{
// money is confirmed and the amount is right — do your thing
}
}
use Pongsit\Scb\{Client, Webhook};
$webhook = new Webhook(new Client($config), function ($message, $context) {
error_log($message . ' ' . json_encode($context));
});
$result = $webhook->handle(null, new OrderStore());
$webhook->acknowledge($result);
if ($result->needsAttention()) {
// underpaid, or a reference we don't recognise — worth an alert
}
use Pongsit\Scb\Verify;
$verify = new Verify(new Client($config));
$txn = $verify->byReference('2026-07-23', 'AJNUNU', '142'); // bank agnostic
$txn = $verify->byTransactionId($transactionId, $sendingBank); // bank code
bash
php tests/offline-test.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.