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

অ্যাপ ডাউনলোড

অটোমেটিক SMS ভেরিফিকেশনের জন্য আমাদের অ্যান্ড্রয়েড অ্যাপটি ডাউনলোড করে আপনার ফোনে ইনস্টল করুন।

অথেনটিকেশন

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

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

POST https://getway.an24.xyz/api/create
{
  "amount": 500,
  "customer_name": "Rahim",
  "success_url": "https://shop.com/success",
  "cancel_url": "https://shop.com/cancel",
  "webhook_url": "https://shop.com/webhook",
  "metadata": {"order_id": "A100"}
}

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

{"success":true,"payment_id":"...","payment_url":"https://..."}

২. যাচাই

GET https://getway.an24.xyz/api/verify?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, cancelled। অর্ডার দেওয়ার আগে status ও amount মিলিয়ে নিন।

৩. PHP উদাহরণ

$ch = curl_init('https://getway.an24.xyz/api/create');
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]),
]);
$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;
}