ডেভেলপার ডকুমেন্টেশন

অথেনটিকেশন

ড্যাশবোর্ড → ব্র্যান্ড থেকে API Key নিন। প্রতিটি রিকোয়েস্টে X-API-KEY হেডার দিন। Key শুধু সার্ভারে রাখুন।

১. পেমেন্ট তৈরি

POST http://bestofflink.cyou/api/create.php

{
  "amount": 500,
  "customer_name": "Rahim",
  "customer_contact": "01700000000",
  "success_url": "https://shop.com/success",
  "cancel_url": "https://shop.com/cancel",
  "webhook_url": "https://shop.com/webhook",
  "metadata": {"order_id": "A100"}
}

রেসপন্স:

{"success":true,"payment_id":"…","payment_url":"http://bestofflink.cyou/pay.php?id=…"}

কাস্টমারকে payment_url-এ পাঠান।

২. পেমেন্ট যাচাই

GET http://bestofflink.cyou/api/verify.php?payment_id=ID

{"success":true,"payment_id":"…","amount":"500.00","status":"completed","trx_id":"…","sender_number":"…","metadata":{"order_id":"A100"}}

Status: created, pending, completed, rejected। অর্ডার দেওয়ার আগে অবশ্যই status = completed এবং amount মিলিয়ে নিন।

৩. PHP উদাহরণ

$ch = curl_init('http://bestofflink.cyou/api/create.php');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_KEY', 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode(['amount' => 500, 'success_url' => 'https://shop.com/success']),
]);
$res = json_decode(curl_exec($ch), true);
header('Location: ' . $res['payment_url']);

৪. ওয়েবহুক

স্ট্যাটাস বদলালে JSON POST যাবে, X-Signature = HMAC-SHA256(body, Secret Key)। একবারই পাঠানো হয়, তাই verify API-ও ব্যবহার করুন।

$body = file_get_contents('php://input');
if (!hash_equals(hash_hmac('sha256', $body, $secret), $_SERVER['HTTP_X_SIGNATURE'] ?? '')) { http_response_code(401); exit; }