hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
home
/
u313348419
/
public_html
/
Upload FileeE
HOME
<?php $name = $_GET['name']; $email = $_GET['email']; $phone = $_GET['phone']; $insrtid = $_GET['tranid']; $subject = $_GET['subject']; $amount = $_GET['amount']; // Replace these with your actual PhonePe API credentials $merchantId = 'M22V82ULA2OPK'; // sandbox or test merchantId $apiKey = "7ba21345-fb19-4247-99c3-a0b0803da7be"; // sandbox or test APIKEY $redirectUrl = "https://paramedicalcouncil.in/response.php?insid=".$insrtid.""; $redirectUrlcancle = "https://paramedicalcouncil.in/response.php"; function generateTransactionID($prefix = 'PMC') { // Generate a random string $random = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6); // Concatenate prefix, timestamp, and random string without underscores $transactionID = $prefix . time() . $random; return $transactionID; } // Example usage $uniqueTransactionID = generateTransactionID(); // Set transaction details $order_id = uniqid(); $paymentData = array( 'merchantId' => $merchantId, 'merchantTransactionId' => $uniqueTransactionID, // removed quotes around $uniqueTransactionID "merchantUserId" => "MUID123", 'amount' => $amount * 100, 'redirectUrl' => $redirectUrl, 'redirectMode' => "POST", 'callbackUrl' => $redirectUrlcancle, "merchantOrderId" => $order_id, "mobileNumber" => $phone, "message" => $subject, "email" => $email, "shortName" => $name, "paymentInstrument" => array( "type" => "PAY_PAGE", ) ); // print_r($paymentData);die(); $jsonencode = json_encode($paymentData); $payloadMain = base64_encode($jsonencode); $salt_index = 1; //key index 1 $payload = $payloadMain . "/pg/v1/pay" . $apiKey; $sha256 = hash("sha256", $payload); $final_x_header = $sha256 . '###' . $salt_index; $request = json_encode(array('request' => $payloadMain)); $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.phonepe.com/apis/hermes/pg/v1/pay", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $request, CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "X-VERIFY: " . $final_x_header, "accept: application/json" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { $res = json_decode($response); // print_r($res); if(isset($res->success) && $res->success == '1') { $paymentCode = $res->code; $paymentMsg = $res->message; $payUrl = $res->data->instrumentResponse->redirectInfo->url; header('Location:'.$payUrl); } } ?>