PHP SDK

A single-file client: create payments, read them back, verify webhooks. No Composer.

Updated 22 Nov 2026 · 1 min read

PayGateClient.php is one file with no dependencies (cURL when present, PHP streams otherwise). PHP 7.4 or newer.

Take a payment

require 'PayGateClient.php';
$pg = new PayGateClient('https://pay.example.com', 'pk_live_…', 'sk_live_…');

$payment = $pg->createPayment([
    'amount'      => '500.00',
    'currency'    => 'BDT',
    'reference'   => 'ORDER-1001',
    'customer'    => ['name' => 'Rahim', 'phone' => '01712345678'],
    'success_url' => 'https://shop.example.com/thanks',
    'cancel_url'  => 'https://shop.example.com/cart',
    'webhook_url' => 'https://shop.example.com/ipn.php',
]);
header('Location: ' . $payment['checkout_url']);

Other methods

MethodAPI
getPayment('PAY…')GET /api/v1/payments/{id}
findByReference('ORDER-1001')GET /api/v1/payments?reference=
cancel('PAY…')POST /api/v1/payments/{id}/cancel
verify('PAY…', 'bkash', 'TRXID', '017…')POST /api/v1/payments/{id}/verify
methods(500, 'BDT')GET /api/v1/methods
createInvoice([...]), createLink([...])invoices and links

Every failed call throws PayGateException with errorCode, httpStatus and the decoded response.

Webhooks

$raw = file_get_contents('php://input');
try {
    $event = PayGateClient::verifyWebhook($raw, $_SERVER, 'sk_live_…');
} catch (PayGateException $e) {
    http_response_code(400); exit;
}
if ($event['event'] === 'payment.completed') {
    $p = $event['data']['payment'];
    // check amount / currency / reference against your order, then mark it paid
}
echo 'ok';