/
/
home
/
u523034047
/
domains
/
psassociate.org
/
public_html
/
phonepe
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.60
PHP 8.3.16
Dir:
/home/u523034047/domains/psassociate.org/public_html/phonepe
Edit:
/home/u523034047/domains/psassociate.org/public_html/phonepe/callback.php
<?php error_reporting(0); ini_set('display_errors', 0); ob_start(); require_once __DIR__ . '/phonepe_config.php'; $logDir = __DIR__ . '/logs/'; if (!is_dir($logDir)) @mkdir($logDir, 0755, true); $requestMethod = $_SERVER['REQUEST_METHOD'] ?? 'UNKNOWN'; @file_put_contents( $logDir . date('Y-m-d') . '.log', '[' . date('Y-m-d H:i:s') . '] [CALLBACK_HIT] ' . json_encode(['method' => $requestMethod, 'ip' => $_SERVER['REMOTE_ADDR']]) . "\n", FILE_APPEND | LOCK_EX ); if ($requestMethod === 'POST') { $postBody = file_get_contents('php://input'); $data = json_decode($postBody, true); // Decode base64 response for S2S if (!empty($data['response'])) { $decodedResponse = json_decode(base64_decode($data['response']), true); $orderId = $decodedResponse['merchantOrderId'] ?? ''; $state = $decodedResponse['state'] ?? ''; if ($state === 'COMPLETED' && !empty($orderId)) { require_once __DIR__ . '/phonepe_config.php'; // Extract metadata from S2S response $metaData = parseUdfData($decodedResponse['metaInfo'] ?? []); logPayment('S2S_METADATA_RECOVERY', ['order_id' => $orderId, 'found' => !empty($metaData)]); // Send emails if we have the metadata if (!empty($metaData['email'])) { $adminSubject = "New Application + Payment - " . $metaData['name']; $adminBody = "New Resume Submission (S2S Webhook)\n---------------------\n\n"; foreach ($metaData as $k => $v) $adminBody .= ucfirst($k) . ": $v\n"; $adminBody .= "\nResume: https://psassociate.org/admin/Career/" . $metaData['resume']; sendEmail(ADMIN_EMAIL, $adminSubject, $adminBody, $metaData['email']); $userSubject = "Payment Confirmation - PS Associate"; $userBody = "Hi " . $metaData['name'] . ",\n\nYour payment of " . $metaData['payment_amount'] . " is confirmed.\n\nOur team will review your resume shortly."; sendEmail($metaData['email'], $userSubject, $userBody, ADMIN_EMAIL); } } } ob_end_clean(); http_response_code(200); header('Content-Type: application/json'); echo json_encode(['status' => 'OK']); exit; } ob_end_clean(); session_start(); $orderId = $_GET['merchantOrderId'] ?? $_SESSION['career']['order_id'] ?? ''; if (empty($orderId)) { header("Location: failed.php?reason=MISSING_ORDER_ID"); exit; } $token = getPhonePeToken(); $statusUrl = PHONEPE_STATUS_URL . '/' . urlencode($orderId) . '/status'; $ch = curl_init($statusUrl); curl_setopt_array($ch, [ CURLOPT_HTTPGET => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: O-Bearer ' . $token], CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_TIMEOUT => 30, ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); $orderState = $result['state'] ?? 'UNKNOWN'; if ($orderState === 'COMPLETED') { // Recover session from metadata if lost $metaData = parseUdfData($result['metaInfo'] ?? []); if (!empty($metaData)) { $_SESSION['career'] = $metaData; $_SESSION['career']['order_id'] = $orderId; $_SESSION['career']['transaction_id'] = $result['orderId'] ?? $orderId; $_SESSION['career']['payment_status'] = 'SUCCESS'; $_SESSION['career']['emails_sent'] = true; } header("Location: success.php"); exit; } header("Location: failed.php?reason=" . urlencode($orderState)); exit; ?>
Ukuran: 3.5 KB