PHP SDK

এক ফাইলের ক্লায়েন্ট: পেমেন্ট তৈরি, দেখা, webhook যাচাই। Composer লাগে না।

হালনাগাদ ২২ নভেম্বর ২০২৬ · ১ মিনিটে পড়া

PayGateClient.php এক ফাইলের, কোনো dependency নেই (cURL থাকলে cURL, না থাকলে PHP stream)। PHP 7.4 বা নতুন।

পেমেন্ট নেওয়া

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']);

অন্য মেথড

মেথডAPI
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([...])ইনভয়েস আর লিংক

ব্যর্থ প্রতিটা কল errorCode, httpStatus আর decode করা response সহ PayGateException ছোড়ে।

Webhook

$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'];
    // আপনার অর্ডারের সাথে amount / currency / reference মিলিয়ে তারপর পেইড করুন
}
echo 'ok';