<?php
// Sample random payload
$data = [
    "transactionReference" => uniqid("TXN_"),
    "paymentStatus" => "PAID",
    "amountPaid" => rand(1000, 10000),
    "customerEmail" => "student" . rand(100, 999) . "@schoolmata.com.ng",
    "paymentMethod" => "CARD",
    "paidOn" => date("Y-m-d H:i:s"),
    "product" => "Post-UTME Registration"
];

// Encode the data as JSON
$input = json_encode($data);

// Decode input just to follow your original pattern
$res = json_decode($input, true);

// Forward request to schoolmata
$forward_url = "https://schoolmata.com.ng/mobile/api/monnify/webhook.php";
$ch = curl_init($forward_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input);

// Set headers for forwarded request
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Content-Length: ' . strlen($input)
]);

// Execute request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Output response
echo "HTTP Code: $httpCode\n";
echo "Response: $response\n";
