<?php
include '../../config.php';

$settings_res = $connect->query("SELECT active_payment_gateway FROM settings WHERE botid = '$botid' LIMIT 1");
$gateway = 'zarinpal'; // پیشفرض
if ($settings_res->num_rows > 0) {
    $row = $settings_res->fetch_assoc();
    $gateway = $row['active_payment_gateway'];
}

$user_id = $_GET['id'] ?? null;
$amount = $_GET['amount'] ?? 0;

$query_string = http_build_query([
    'id' => $user_id,
    'amount' => $amount
]);

switch ($gateway) {
    case 'payping':
        header("Location: payping/index.php?" . $query_string);
        break;
    case 'zibal':
        header("Location: zibal/index.php?" . $query_string);
        break;
    case 'zarinpal':
    default:
        header("Location: zarinpal/index.php?" . $query_string);
        break;
}
exit;
?>