!
Domain whitelist required
ইন্টিগ্রেশন শেষ হলে আপনার ডোমেইন লিংক WhatsApp-এ 01961-394010 নম্বরে পাঠান। আমরা হোয়াইটলিস্ট করে দেব, তারপর পেমেন্ট লাইভ হবে।
Free sandbox
Test the API in minutes
Use this test key and base URL to try payments before you go live. Send the key as Authorization: Bearer YOUR_KEY.
Base URL
https://payment.themedokan.com/apiTest API key
c21679f072261f13b19b8a801d02041c90eaadd6f8460b2f7c
Endpoints
POST
https://payment.themedokan.com/api/create-paymentCreate a payment — returns checkout_urlPOST
https://payment.themedokan.com/api/verify-paymentVerify a payment with pp_idPOST
https://payment.themedokan.com/api/refund-paymentRefund a paymentANY
https://payment.themedokan.com/api/checkout/redirectCheckout redirectDocumentation
Deshi Pay
ডাউনলোড
WordPress, WHMCS, SMM Panel ও SDK এখান থেকে ডাউনলোড করুন।
Downloads
Download the WordPress plugin, WHMCS module, SMM panel files and the SDK from here.
১. কীভাবে কাজ করে
- Brands → API Setting থেকে আপনার API Key নিন।
- আপনার সাইট থেকে
POST https://payment.themedokan.com/api/create-paymentকল করুন (Header:Authorization: Bearer API_KEY)। - রেসপন্সে পাওয়া
checkout_url-এ কাস্টমারকে পাঠান। - পেমেন্ট হলে Deshi Pay আপনার
webhook_url-এ POST করে। এরপরPOST /api/verify-paymentদিয়েpp_idযাচাই করে অর্ডার পেইড করুন।
1. How it works
- Get your API Key from Brands → API Setting.
- Call
POST https://payment.themedokan.com/api/create-paymentfrom your site (Header:Authorization: Bearer API_KEY). - Redirect the customer to the returned
checkout_url. - When paid, Deshi Pay POSTs to your
webhook_url. Verifypp_idviaPOST /api/verify-payment, then mark the order paid.
Alternative header: mhs-deshipay-api-key: API_KEY
যেকোনো PHP ওয়েবসাইটে (নিজের তৈরি PHP, CodeIgniter ইত্যাদি) Deshi Pay বসানোর ২টি উপায় আছে। একটি বেছে নিন:
৩টি URL (সবগুলো আপনার নিজের ওয়েবসাইটের):
- উপায় ১ (সবচেয়ে সহজ): মাত্র ১টি ফাইল। সাইটের রুটে
deshipay.phpবানিয়ে সব কোড Paste করুন, তারপর অর্ডার পেজে বাটন বসান। ব্যস। - উপায় ২: আলাদা আলাদা ফাইল।
deshipayফোল্ডারে ৮টি ফাইল, প্রতিটির নাম ও কোড আলাদা দেওয়া আছে।
https://payment.themedokan.com) নিজে থেকেই বসে গেছে। আপনাকে শুধু নিজের ওয়েবসাইটের ঠিকানা, API Key ও ডাটাবেস তথ্য বসাতে হবে।৩টি URL (সবগুলো আপনার নিজের ওয়েবসাইটের):
return_url→ পেমেন্ট সফল হলে কাস্টমার এখানে ফেরেcancel_url→ কাস্টমার Cancel and return to merchant চাপলে এখানে ফেরেwebhook_url→ পেমেন্ট সম্পূর্ণ হলে Deshi Pay নিজে কল করে
id, total, customer_name, customer_email, customer_mobile, status, pp_id কলাম (নাম অন্য হলে কোডে বদলে নিন)।Two ways to add Deshi Pay to any PHP website (custom PHP, CodeIgniter ...). Pick one:
The 3 URLs (all on YOUR website):
- Way 1 (easiest): just ONE file. Create
deshipay.phpin your site root, paste all the code, then add the button to your order page. Done. - Way 2: separate files. 8 files inside a
deshipayfolder, each one with its own name and code.
https://payment.themedokan.com) is already filled in for you. You only add your own website address, API key and database login.The 3 URLs (all on YOUR website):
return_url→ the customer comes back here after payingcancel_url→ the customer comes back here after pressing Cancel and return to merchantwebhook_url→ Deshi Pay calls it by itself when a payment is completed
id, total, customer_name, customer_email, customer_mobile, status, pp_id (if your column names are different, change them in the code).WAY 1 — ONE FILE (easiest)
শুধু এই ১টি ফাইল + ১টি বাটন। নিচের ২টি ধাপ করলেই হবে।
Only this 1 file + 1 button. Just do the 2 steps below.
1File:
deshipay.phpধাপ ১: সাইটের রুটে (যেখানে
index.php আছে) deshipay.php নামে ফাইল বানান এবং পুরো কোড Paste করুন। শুধু ১ ও ২ নম্বর অংশ বদলান: site_url, api_key আর ডাটাবেস লগইন/টেবিল/কলামের নাম। ৩ ও ৪ নম্বর অংশ বদলাবেন না।Step 1: In your site root (where
index.php is) create a file named deshipay.php and paste all the code. Edit only parts 1 and 2: site_url, api_key and the database login / table / column names. Do not change parts 3 and 4.<?php
/**
* Deshi Pay - ONE FILE integration for any PHP website
* File: deshipay.php (put it in the root of your website, next to index.php)
*
* This single file handles everything:
* /deshipay.php?a=pay the "Pay now" button posts here
* /deshipay.php?a=success return_url - the customer paid and comes back
* /deshipay.php?a=cancel cancel_url - the customer pressed "Cancel and return to merchant"
* /deshipay.php?a=webhook webhook_url - Deshi Pay calls it by itself (server to server)
*/
/* ===================== 1) SETTINGS - edit these 4 lines ===================== */
$DP = [
'gateway_url' => 'https://payment.themedokan.com', // Deshi Pay domain (already filled for you)
'api_key' => 'YOUR_DESHIPAY_API_KEY', // Deshi Pay admin > Brands > API Setting
'currency' => 'BDT',
'site_url' => 'https://your-website.com', // YOUR website (no slash at the end)
];
/* ===================== 2) YOUR ORDERS - connect to your own database =====================
* Change the database login, the table name (orders) and the column names to match your site.
* Expected columns: id, total, customer_name, customer_email, customer_mobile, status ('pending' / 'paid'), pp_id
* (run this once in phpMyAdmin: ALTER TABLE orders ADD COLUMN pp_id VARCHAR(40) NULL; )
*/
function dp_db()
{
static $pdo = null;
if ($pdo === null) {
$pdo = new PDO(
'mysql:host=localhost;dbname=YOUR_DB_NAME;charset=utf8mb4',
'YOUR_DB_USER',
'YOUR_DB_PASSWORD',
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]
);
}
return $pdo;
}
/** One order or null. The AMOUNT must come from your database, never from the browser. */
function dp_get_order($id)
{
$st = dp_db()->prepare('SELECT id, total, customer_name, customer_email, customer_mobile, status, pp_id FROM orders WHERE id = ? LIMIT 1');
$st->execute([$id]);
$r = $st->fetch();
if (!$r) {
return null;
}
return ['id' => $r['id'], 'amount' => (float) $r['total'], 'name' => $r['customer_name'], 'email' => $r['customer_email'],
'mobile' => $r['customer_mobile'], 'status' => $r['status'], 'pp_id' => $r['pp_id']];
}
function dp_save_pp_id($id, $ppId)
{
dp_db()->prepare('UPDATE orders SET pp_id = ? WHERE id = ?')->execute([$ppId, $id]);
}
/** Mark the order PAID. Safe to call many times: only the first call changes the order. */
function dp_mark_paid($id, $trxId = '')
{
$st = dp_db()->prepare("UPDATE orders SET status = 'paid' WHERE id = ? AND status <> 'paid'");
$st->execute([$id]);
if ($st->rowCount() === 1) {
// >>> your own code here, runs only once per order (send email, give download, add balance ...) <<<
return true;
}
return false;
}
/* ===================== 3) Deshi Pay API - do not edit ===================== */
function dp_api($path, array $payload)
{
global $DP;
$ch = curl_init(rtrim($DP['gateway_url'], '/') . $path);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $DP['api_key'], 'Content-Type: application/json', 'Accept: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($body === false) {
return ['error' => ['message' => $err ?: 'Connection failed']];
}
$json = json_decode($body, true);
return is_array($json) ? $json : ['error' => ['message' => 'Invalid response from Deshi Pay']];
}
function dp_page($title, $html)
{
echo '<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>' . htmlspecialchars($title) . '</title>'
. '<style>body{font-family:system-ui,Arial,sans-serif;background:#f1f5f9;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0}'
. '.box{background:#fff;border-radius:16px;padding:32px;max-width:380px;text-align:center;box-shadow:0 10px 30px rgba(15,23,42,.08)}'
. 'p{color:#64748b} a{display:inline-block;margin:14px 4px 0;background:#0d67fb;color:#fff;padding:10px 22px;border-radius:10px;text-decoration:none}</style></head>'
. '<body><div class="box">' . $html . '</div></body></html>';
exit;
}
/* ===================== 4) The pages - do not edit ===================== */
$action = $_GET['a'] ?? '';
$site = rtrim($DP['site_url'], '/');
// ---- the "Pay now" button posts here ----
if ($action === 'pay') {
$orderId = (int) ($_POST['order_id'] ?? 0);
$order = dp_get_order($orderId);
if (!$order || $order['status'] === 'paid' || $order['amount'] <= 0) {
dp_page('Invalid order', '<h2>Invalid order</h2><p>This order is invalid or already paid.</p>');
}
$res = dp_api('/api/create-payment', [
'amount' => $order['amount'],
'currency' => $DP['currency'],
'full_name' => $order['name'] ?: 'Customer',
'email_address' => $order['email'],
'mobile_number' => $order['mobile'],
'return_url' => $site . '/deshipay.php?a=success&order=' . $orderId,
'cancel_url' => $site . '/deshipay.php?a=cancel&order=' . $orderId,
'webhook_url' => $site . '/deshipay.php?a=webhook',
'metadata' => ['order_id' => $orderId],
]);
if (!empty($res['status']) && !empty($res['checkout_url'])) {
dp_save_pp_id($orderId, basename(parse_url($res['checkout_url'], PHP_URL_PATH)));
header('Location: ' . $res['checkout_url']);
exit;
}
dp_page('Payment error', '<h2>Payment error</h2><p>' . htmlspecialchars($res['error']['message'] ?? 'Could not create the payment') . '</p>');
}
// ---- return_url: the customer paid and comes back ----
if ($action === 'success') {
$orderId = (int) ($_GET['order'] ?? 0);
$order = dp_get_order($orderId);
$paid = false;
if ($order && $order['pp_id']) {
$v = dp_api('/api/verify-payment', ['pp_id' => $order['pp_id']]);
if (($v['status'] ?? '') === 'completed' && (float) ($v['amount'] ?? 0) + 0.0001 >= $order['amount']) {
dp_mark_paid($orderId, $v['transaction_id'] ?? '');
$paid = true;
}
}
if ($paid) {
dp_page('Payment successful', '<h2>✅ Payment successful</h2><p>Thank you! Your order #' . $orderId . ' is paid.</p><a href="/">Back to the website</a>');
}
dp_page('Payment status', '<h2>⌛ Payment not confirmed yet</h2><p>If you already paid, it will be updated within a minute.</p><a href="/">Back to the website</a>');
}
// ---- cancel_url: the customer pressed "Cancel and return to merchant" ----
if ($action === 'cancel') {
$orderId = (int) ($_GET['order'] ?? 0);
dp_page('Payment cancelled', '<h2>Payment cancelled</h2><p>No money was taken. You can try again any time.</p><a href="/">Home</a>');
}
// ---- webhook_url: Deshi Pay calls this when a payment is completed ----
if ($action === 'webhook') {
$data = json_decode(file_get_contents('php://input'), true);
$ppId = is_array($data) ? ($data['pp_id'] ?? '') : '';
if ($ppId === '') {
http_response_code(400);
exit('pp_id missing');
}
$v = dp_api('/api/verify-payment', ['pp_id' => $ppId]); // never trust the body, ask Deshi Pay
if (($v['status'] ?? '') === 'completed') {
$orderId = (int) ($v['metadata']['order_id'] ?? 0);
$order = $orderId ? dp_get_order($orderId) : null;
if ($order && (float) ($v['amount'] ?? 0) + 0.0001 >= $order['amount']) {
dp_mark_paid($orderId, $v['transaction_id'] ?? '');
}
}
http_response_code(200);
exit('OK');
}
http_response_code(404);
echo 'Not found';2File:
Your order page (HTML) — for Way 1ধাপ ২: আপনার অর্ডার/চেকআউট পেজে যেখানে বাটন চান সেখানে এই ফর্ম বসান।
123-এর জায়গায় আসল অর্ডার আইডি বসান।Step 2: Paste this form on your order / checkout page where you want the button. Replace
123 with the real order id.<!-- Paste this on your order / checkout page, where the customer sees "Pay now".
Replace 123 with the real order id (in PHP: value="<?= $order['id'] ?>" ). -->
<form method="post" action="/deshipay.php?a=pay">
<input type="hidden" name="order_id" value="123">
<button type="submit">Pay with Deshi Pay (bKash / Nagad / Rocket / Bangla QR)</button>
</form>WAY 2 — SEPARATE FILES
সব ফাইল সাইটের রুটের
deshipay ফোল্ডারে থাকবে। ফোল্ডার ও ফাইলের গঠন:your-website/
└── deshipay/
├── config.php (settings)
├── DeshiPay.php (helper)
├── orders.php (connect YOUR orders)
├── pay.php (Pay now)
├── success.php (return_url)
├── cancel.php (cancel_url)
└── webhook.php (webhook_url)All files go in a
deshipay folder in your site root. The structure:your-website/
└── deshipay/
├── config.php (settings)
├── DeshiPay.php (helper)
├── orders.php (connect YOUR orders)
├── pay.php (Pay now)
├── success.php (return_url)
├── cancel.php (cancel_url)
└── webhook.php (webhook_url)3File:
deshipay/db.sql(ঐচ্ছিক) আপনার অর্ডার টেবিলে Deshi Pay-এর payment id রাখার কলাম। phpMyAdmin → SQL ট্যাবে Paste করে Go চাপুন।
orders নামটি আপনার টেবিলের নামে বদলান। (উপায় ১-এও এটি লাগবে, যদি pp_id কলাম না থাকে)(optional) A column on your orders table that keeps the Deshi Pay payment id. phpMyAdmin → SQL tab, paste and click Go. Change
orders to your table name. (Way 1 needs it too, if you have no pp_id column yet)-- OPTIONAL. Run in phpMyAdmin (change `orders` to the name of YOUR orders table). -- Deshi Pay gives every payment an id (pp_id). We keep it on the order so we can verify it later. ALTER TABLE `orders` ADD COLUMN `pp_id` VARCHAR(40) NULL, ADD INDEX `idx_pp_id` (`pp_id`);
4File:
deshipay/config.phpফাইল ১: gateway_url বসানো আছে। আপনি শুধু api_key (Brands → API Setting থেকে) ও site_url (আপনার ওয়েবসাইট) বসান।
File 1: gateway_url is already filled. You only set api_key (from Brands → API Setting) and site_url (your website).
<?php
/**
* File: deshipay/config.php (edit the 4 values)
*/
return [
// Deshi Pay (the gateway) domain - no slash at the end
'gateway_url' => 'https://payment.themedokan.com',
// Deshi Pay admin > Brands > API Setting (turn ON: Create Payment + Verify Payment)
'api_key' => 'YOUR_DESHIPAY_API_KEY',
'currency' => 'BDT',
// YOUR website, where the deshipay/ folder is uploaded - no slash at the end
// return_url, cancel_url and webhook_url below are built from this
'site_url' => 'https://your-website.com',
];5File:
deshipay/DeshiPay.phpফাইল ২: সাহায্যকারী ক্লাস (পেমেন্ট তৈরি ও ভেরিফাই)। কিছু বদলাতে হবে না।
File 2: the helper class (create payment and verify). Nothing to edit.
<?php
/**
* File: deshipay/DeshiPay.php (helper class - nothing to edit)
*/
class DeshiPay
{
private $gatewayUrl;
private $apiKey;
public function __construct($gatewayUrl, $apiKey)
{
$this->gatewayUrl = rtrim($gatewayUrl, '/');
$this->apiKey = $apiKey;
}
/**
* Create a payment. Returns ['ok' => true, 'checkout_url' => '...', 'pp_id' => '...']
* or ['ok' => false, 'message' => '...']
*/
public function createPayment(array $payload)
{
$res = $this->call('/api/create-payment', $payload);
if (!empty($res['status']) && !empty($res['checkout_url'])) {
return [
'ok' => true,
'checkout_url' => $res['checkout_url'],
'pp_id' => basename(parse_url($res['checkout_url'], PHP_URL_PATH)),
];
}
return ['ok' => false, 'message' => $res['error']['message'] ?? 'Could not create the payment'];
}
/** Ask Deshi Pay about a payment. Never trust the browser or the webhook body - always call this. */
public function verifyPayment($ppId)
{
return $this->call('/api/verify-payment', ['pp_id' => $ppId]);
}
private function call($path, array $payload)
{
$ch = curl_init($this->gatewayUrl . $path);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $this->apiKey,
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($body === false) {
return ['error' => ['message' => $err ?: 'Connection failed']];
}
$json = json_decode($body, true);
return is_array($json) ? $json : ['error' => ['message' => 'Invalid response from Deshi Pay']];
}
}6File:
deshipay/orders.phpফাইল ৩: এটিই একমাত্র ফাইল যেটা আপনার সাইটের সাথে জুড়তে হবে। ডাটাবেস লগইন, টেবিলের নাম (
orders) ও কলামের নাম আপনার সাইট অনুযায়ী বদলান। deshipay_mark_paid()-এর ভেতরে আপনার নিজের কাজ (ইমেইল, ডাউনলোড, ব্যালেন্স যোগ) বসান; সেটি প্রতি অর্ডারে একবারই চলবে।File 3: this is the only file you must connect to your own site. Change the database login, the table name (
orders) and the column names to match your site. Put your own work (email, download, add balance) inside deshipay_mark_paid(); it runs only once per order.<?php
/**
* File: deshipay/orders.php
* THIS IS THE ONLY FILE YOU MUST CONNECT TO YOUR OWN SITE.
* Change the database login, the table name (orders) and the column names so they match your site.
*
* Expected columns in your orders table (rename below if yours are different):
* id, total, customer_name, customer_email, customer_mobile, status ('pending' / 'paid'), pp_id
*/
function deshipay_db()
{
static $pdo = null;
if ($pdo === null) {
$pdo = new PDO(
'mysql:host=localhost;dbname=YOUR_DB_NAME;charset=utf8mb4',
'YOUR_DB_USER',
'YOUR_DB_PASSWORD',
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]
);
}
return $pdo;
}
/** Return one order, or null. The AMOUNT must come from here (your database), never from the browser. */
function deshipay_get_order($orderId)
{
$st = deshipay_db()->prepare('SELECT id, total, customer_name, customer_email, customer_mobile, status, pp_id FROM orders WHERE id = ? LIMIT 1');
$st->execute([$orderId]);
$row = $st->fetch();
if (!$row) {
return null;
}
return [
'id' => $row['id'],
'amount' => (float) $row['total'],
'name' => $row['customer_name'],
'email' => $row['customer_email'],
'mobile' => $row['customer_mobile'],
'status' => $row['status'],
'pp_id' => $row['pp_id'],
];
}
/** Remember the Deshi Pay payment id on the order. */
function deshipay_save_pp_id($orderId, $ppId)
{
deshipay_db()->prepare('UPDATE orders SET pp_id = ? WHERE id = ?')->execute([$ppId, $orderId]);
}
/**
* Mark the order as PAID. Add your own extra work here (send email, give download, add balance ...).
* It must be safe to call many times: only the first call changes the order.
* Returns true only when this call really changed the order.
*/
function deshipay_mark_paid($orderId, $trxId = '')
{
$st = deshipay_db()->prepare("UPDATE orders SET status = 'paid' WHERE id = ? AND status <> 'paid'");
$st->execute([$orderId]);
if ($st->rowCount() === 1) {
// >>> your own code, runs only once per order <<<
// mail($email, 'Payment received', 'Thank you!');
return true;
}
return false;
}7File:
deshipay/pay.phpফাইল ৪: "Pay now" ফর্ম এখানে POST করে। অর্ডারের টাকা আপনার ডাটাবেস থেকে নেওয়া হয় (ব্রাউজার থেকে নয়), পেমেন্ট তৈরি করে কাস্টমারকে Deshi Pay-তে পাঠায়। এখানেই
return_url, cancel_url ও webhook_url দেওয়া আছে।File 4: the "Pay now" form posts here. The amount is read from your database (never from the browser). It creates the payment and sends the customer to Deshi Pay.
return_url, cancel_url and webhook_url are set here.<?php
/**
* File: deshipay/pay.php
* The "Pay now" button posts here. It creates the payment and sends the customer to Deshi Pay.
*/
require __DIR__ . '/DeshiPay.php';
require __DIR__ . '/orders.php';
$cfg = require __DIR__ . '/config.php';
$orderId = (int) ($_POST['order_id'] ?? 0);
$order = deshipay_get_order($orderId);
if (!$order || $order['status'] === 'paid' || $order['amount'] <= 0) {
exit('Invalid or already paid order.');
}
$deshi = new DeshiPay($cfg['gateway_url'], $cfg['api_key']);
$site = rtrim($cfg['site_url'], '/');
$res = $deshi->createPayment([
'amount' => $order['amount'], // from YOUR database
'currency' => $cfg['currency'],
'full_name' => $order['name'] ?: 'Customer',
'email_address' => $order['email'],
'mobile_number' => $order['mobile'],
// where the customer comes back to (all three are pages of YOUR website)
'return_url' => $site . '/deshipay/success.php?order=' . $orderId, // payment done
'cancel_url' => $site . '/deshipay/cancel.php?order=' . $orderId, // customer pressed "Cancel and return to merchant"
'webhook_url' => $site . '/deshipay/webhook.php', // Deshi Pay calls this (server to server)
'metadata' => ['order_id' => $orderId],
]);
if ($res['ok']) {
deshipay_save_pp_id($orderId, $res['pp_id']);
header('Location: ' . $res['checkout_url']);
exit;
}
echo 'Payment error: ' . htmlspecialchars($res['message']);8File:
deshipay/success.phpফাইল ৫:
return_url — পেমেন্টের পর কাস্টমার এই পেজে ফেরে। Deshi Pay-কে জিজ্ঞেস করে যাচাই করে অর্ডার Paid করে।File 5:
return_url — the customer lands here after paying. It asks Deshi Pay to confirm, then marks the order Paid.<?php
/**
* File: deshipay/success.php
* The customer lands here after paying. We ask Deshi Pay (never trust the URL) and then show the result.
*/
require __DIR__ . '/DeshiPay.php';
require __DIR__ . '/orders.php';
$cfg = require __DIR__ . '/config.php';
$orderId = (int) ($_GET['order'] ?? 0);
$order = deshipay_get_order($orderId);
$paid = false;
if ($order && $order['pp_id']) {
$deshi = new DeshiPay($cfg['gateway_url'], $cfg['api_key']);
$v = $deshi->verifyPayment($order['pp_id']);
if (($v['status'] ?? '') === 'completed' && (float) ($v['amount'] ?? 0) + 0.0001 >= $order['amount']) {
deshipay_mark_paid($orderId, $v['transaction_id'] ?? '');
$paid = true;
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= $paid ? 'Payment successful' : 'Payment status' ?></title>
<style>
body{font-family:system-ui,Arial,sans-serif;background:#f1f5f9;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0}
.box{background:#fff;border-radius:16px;padding:32px;max-width:380px;text-align:center;box-shadow:0 10px 30px rgba(15,23,42,.08)}
p{color:#64748b} a{display:inline-block;margin-top:14px;background:#0d67fb;color:#fff;padding:10px 22px;border-radius:10px;text-decoration:none}
</style>
</head>
<body>
<div class="box">
<?php if ($paid) { ?>
<h2>✅ Payment successful</h2>
<p>Thank you! Your order #<?= (int) $orderId ?> is paid.</p>
<?php } else { ?>
<h2>⌛ Payment not confirmed yet</h2>
<p>If you already paid, it will be updated within a minute.</p>
<?php } ?>
<a href="/">Back to the website</a>
</div>
</body>
</html>9File:
deshipay/cancel.phpফাইল ৬:
cancel_url — কাস্টমার Cancel and return to merchant চাপলে এখানে ফেরে। কোনো টাকা কাটা হয় না, অর্ডার আনপেইড থাকে। "Try again" লিংকটি আপনার চেকআউট পেজের ঠিকানায় বদলান।File 6:
cancel_url — the customer lands here after pressing Cancel and return to merchant. No money is taken and the order stays unpaid. Change the "Try again" link to your own checkout page.<?php
/**
* File: deshipay/cancel.php
* cancel_url: the customer pressed "Cancel and return to merchant" on the Deshi Pay checkout.
* Nothing was paid, so the order stays unpaid. You can change the link below to your own cart / checkout page.
*/
$orderId = (int) ($_GET['order'] ?? 0);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Payment cancelled</title>
<style>
body{font-family:system-ui,Arial,sans-serif;background:#f1f5f9;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0}
.box{background:#fff;border-radius:16px;padding:32px;max-width:380px;text-align:center;box-shadow:0 10px 30px rgba(15,23,42,.08)}
p{color:#64748b} a{display:inline-block;margin:14px 4px 0;background:#0d67fb;color:#fff;padding:10px 22px;border-radius:10px;text-decoration:none}
</style>
</head>
<body>
<div class="box">
<h2>Payment cancelled</h2>
<p>No money was taken<?= $orderId ? ' for order #' . $orderId : '' ?>. You can try again any time.</p>
<a href="/checkout.php?order=<?= $orderId ?>">Try again</a>
<a href="/" style="background:#64748b">Home</a>
</div>
</body>
</html>10File:
deshipay/webhook.phpফাইল ৭:
webhook_url — কাস্টমার ব্রাউজার বন্ধ করে দিলেও Deshi Pay নিজে এই ফাইলকে কল করে অর্ডার Paid করে। কিছু বদলাতে হবে না।File 7:
webhook_url — even if the customer closes the browser, Deshi Pay calls this file and the order is marked Paid. Nothing to edit.<?php
/**
* File: deshipay/webhook.php
* Deshi Pay calls this URL (server to server) when a payment is completed.
* It works even if the customer closes the browser before coming back to your site.
*/
require __DIR__ . '/DeshiPay.php';
require __DIR__ . '/orders.php';
$cfg = require __DIR__ . '/config.php';
$data = json_decode(file_get_contents('php://input'), true);
$ppId = is_array($data) ? ($data['pp_id'] ?? '') : '';
if ($ppId === '') {
http_response_code(400);
exit('pp_id missing');
}
// The body is never trusted: ask Deshi Pay directly.
$deshi = new DeshiPay($cfg['gateway_url'], $cfg['api_key']);
$v = $deshi->verifyPayment($ppId);
if (($v['status'] ?? '') === 'completed') {
$orderId = (int) ($v['metadata']['order_id'] ?? 0);
$order = $orderId ? deshipay_get_order($orderId) : null;
if ($order && (float) ($v['amount'] ?? 0) + 0.0001 >= $order['amount']) {
deshipay_mark_paid($orderId, $v['transaction_id'] ?? '');
}
}
http_response_code(200);
echo 'OK';11File:
Your order page (HTML) — for Way 2ফাইল ৮: আপনার অর্ডার/চেকআউট পেজে যেখানে বাটন চান সেখানে এই ফর্ম বসান।
123-এর জায়গায় আসল অর্ডার আইডি বসান।File 8: paste this form on your order / checkout page where you want the button. Replace
123 with the real order id.<!-- Paste this on your order / checkout page, where the customer sees "Pay now".
Replace 123 with the real order id (e.g. <?= $order['id'] ?> in PHP). -->
<form method="post" action="/deshipay/pay.php">
<input type="hidden" name="order_id" value="123">
<button type="submit">Pay with Deshi Pay (bKash / Nagad / Rocket / Bangla QR)</button>
</form>শেষ ধাপ
- Deshi Pay Admin → Brands → API Setting-এ Create Payment ও Verify Payment চালু আছে কিনা দেখুন।
- একটি ছোট টেস্ট অর্ডার করে পেমেন্ট করুন; অর্ডার টেবিলে status paid হলে কাজ শেষ।
- না হলে: টেবিল ও কলামের নাম মিলিয়ে দেখুন এবং
site_urlআপনার ওয়েবসাইটের সঠিক ঠিকানা কিনা দেখুন। (HTTPS ও সঠিক ডোমেইন হতে হবে, কারণ webhook সেখানেই আসে)
Final steps
- Check that Create Payment and Verify Payment are enabled in Deshi Pay Admin → Brands → API Setting.
- Make a small test order and pay it; when the status in your orders table becomes paid you are done.
- If not: check the table and column names and that
site_urlis your real website address (HTTPS and the right domain, because the webhook arrives there).
Bangla QR গেটওয়ে সেটআপ
- Gateways → Create → Dhaka Pay / bKash / Pathao Pay Bangla QR সিলেক্ট করুন।
- Edit পেজে আপনার Bangla QR ইমেজ আপলোড করুন এবং Auto Verify Time (কত মিনিট অটো ভেরিফাই চলবে) সিলেক্ট করুন।
- আপনার অ্যান্ড্রয়েড ফোনে Deshi Pay - Auto Verification অ্যাপ ইনস্টল করুন (নিচের বাটন থেকে), তারপর MFS Automation → Devices-এ ফোন কানেক্ট রাখুন (SMS পড়ার জন্য)।
- কাস্টমার QR স্ক্যান করে টাকা পাঠালে SMS আসার সাথে সাথে পেমেন্ট অটো কমপ্লিট হবে।
Bangla QR gateway setup
- Gateways → Create → choose Dhaka Pay / bKash / Pathao Pay Bangla QR.
- On the Edit page upload your Bangla QR image and set the Auto Verify Time (minutes the auto-verification stays active).
- Install the Deshi Pay - Auto Verification app on your Android phone (button below), then keep it connected under MFS Automation → Devices (it reads the SMS).
- When the customer scans the QR and pays, the payment completes automatically as soon as the SMS arrives.
