[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: paymentsuccess.php
<?php include("functions.php"); if(!isset($_SESSION['index_no78897498'])){ header("location:index"); } else { $stu_code = $_SESSION['index_no78897498']; $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']; $pstatus = "Paid"; $date = date("Y-m-d"); $save = mysqli_query($new,"INSERT INTO stud_payment(s_code,indexNumber,amount,pstatus,datepaid,transaction_id)VALUES('".$school_code."','".$stu_code."','".$amount."','".$pstatus."','".$date."','".$reference."')"); } } else { // Payment failed or verification unsuccessful $error_message = isset($result['message']) ? $result['message'] : 'Transaction verification failed.'; echo "Error: $error_message"; // Optionally redirect to a failure page // header('Location: payment_failed.php'); } } ?> <!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 { ?> <div class="bg-light-subtle min-vh-100 py-5"> <div class="py-4"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="text-center"> <div class="maintenance-cog-icon text-primary pt-4"> <i class="mdi mdi-cog spin-right display-3"></i> <i class="mdi mdi-cog spin-left display-4 cog-icon"></i> </div> <br /><br /> <h3 class="mt-4">Payment made successfully</h3> <a href="index"><button type="button" class="btn btn-primary">Login to your account</button></a> </div> </div> <!-- end col --> </div> <!-- end row --> </div> <!-- end container --> </div> </div> <!-- 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.81 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