<?php
// Disable all errors and outputs
ini_set('display_errors', 0);
error_reporting(0);
ob_start();

header('Content-Type: application/json');

// ✅ Get currency from request
$currency = strtolower($_POST['currency'] ?? '');

// ✅ Target URLs
$pkr_gateway = 'https://kilicow.rdnslvhost.in.net/paypkr/payinv1';
$inr_gateway = 'https://kilicow.rdnslvhost.in.net/pay/payinr.php';

// ✅ Decide redirect target
switch ($currency) {
    case 'pkr':
        $target = $pkr_gateway;
        break;
    case 'inr':
        $target = $inr_gateway;
        break;
    default:
        echo json_encode(["status" => "error", "message" => "Unsupported or missing currency"]);
        exit;
}

// ✅ Forward POST to the correct API
$ch = curl_init($target);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); // Forward all original POST data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// ✅ Return the response as-is
echo $response;
