Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ncriptech/../ecampus.ncriptech.com/application/helpers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php function encrypt_e($input, $ky) { $key = html_entity_decode($ky); $iv = "@@@@&&&&####$$$$"; $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, $iv ); return $data; } function decrypt_e($crypt, $ky) { $key = html_entity_decode($ky); $iv = "@@@@&&&&####$$$$"; $data = openssl_decrypt ( $crypt , "AES-128-CBC" , $key, 0, $iv ); return $data; } function generateSalt_e($length) { $random = ""; srand((double) microtime() * 1000000); $data = "AbcDE123IJKLMN67QRSTUVWXYZ"; $data .= "aBCdefghijklmn123opq45rs67tuv89wxyz"; $data .= "0FGH45OP89"; for ($i = 0; $i < $length; $i++) { $random .= substr($data, (rand() % (strlen($data))), 1); } return $random; } function checkString_e($value) { if ($value == 'null') $value = ''; return $value; } function getChecksumFromArray($arrayList, $key, $sort=1) { if ($sort != 0) { ksort($arrayList); } $str = getArray2Str($arrayList); $salt = generateSalt_e(4); $finalString = $str . "|" . $salt; $hash = hash("sha256", $finalString); $hashString = $hash . $salt; $checksum = encrypt_e($hashString, $key); return $checksum; } function getChecksumFromString($str, $key) { $salt = generateSalt_e(4); $finalString = $str . "|" . $salt; $hash = hash("sha256", $finalString); $hashString = $hash . $salt; $checksum = encrypt_e($hashString, $key); return $checksum; } function verifychecksum_e($arrayList, $key, $checksumvalue) { $arrayList = removeCheckSumParam($arrayList); ksort($arrayList); $str = getArray2StrForVerify($arrayList); $paytm_hash = decrypt_e($checksumvalue, $key); $salt = substr($paytm_hash, -4); $finalString = $str . "|" . $salt; $website_hash = hash("sha256", $finalString); $website_hash .= $salt; $validFlag = "FALSE"; if ($website_hash == $paytm_hash) { $validFlag = "TRUE"; } else { $validFlag = "FALSE"; } return $validFlag; } function verifychecksum_eFromStr($str, $key, $checksumvalue) { $paytm_hash = decrypt_e($checksumvalue, $key); $salt = substr($paytm_hash, -4); $finalString = $str . "|" . $salt; $website_hash = hash("sha256", $finalString); $website_hash .= $salt; $validFlag = "FALSE"; if ($website_hash == $paytm_hash) { $validFlag = "TRUE"; } else { $validFlag = "FALSE"; } return $validFlag; } function getArray2Str($arrayList) { $findme = 'REFUND'; $findmepipe = '|'; $paramStr = ""; $flag = 1; foreach ($arrayList as $key => $value) { $pos = strpos($value, $findme); $pospipe = strpos($value, $findmepipe); if ($pos !== false || $pospipe !== false) { continue; } if ($flag) { $paramStr .= checkString_e($value); $flag = 0; } else { $paramStr .= "|" . checkString_e($value); } } return $paramStr; } function getArray2StrForVerify($arrayList) { $paramStr = ""; $flag = 1; foreach ($arrayList as $key => $value) { if ($flag) { $paramStr .= checkString_e($value); $flag = 0; } else { $paramStr .= "|" . checkString_e($value); } } return $paramStr; } function redirect2PG($paramList, $key) { $hashString = getchecksumFromArray($paramList); $checksum = encrypt_e($hashString, $key); } function removeCheckSumParam($arrayList) { if (isset($arrayList["CHECKSUMHASH"])) { unset($arrayList["CHECKSUMHASH"]); } return $arrayList; } function getTxnStatus($requestParamList) { return callAPI(PAYTM_STATUS_QUERY_URL, $requestParamList); } function getTxnStatusNew($requestParamList,$PAYTM_STATUS_QUERY_NEW_URL) { return callNewAPI($PAYTM_STATUS_QUERY_NEW_URL, $requestParamList); } function initiateTxnRefund($requestParamList) { $CHECKSUM = getRefundChecksumFromArray($requestParamList,PAYTM_MERCHANT_KEY,0); $requestParamList["CHECKSUM"] = $CHECKSUM; return callAPI(PAYTM_REFUND_URL, $requestParamList); } function callAPI($apiURL, $requestParamList) { $jsonResponse = ""; $responseParamList = array(); $JsonData =json_encode($requestParamList); $postData = 'JsonData='.urlencode($JsonData); $ch = curl_init($apiURL); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($postData)) ); $jsonResponse = curl_exec($ch); $responseParamList = json_decode($jsonResponse,true); return $responseParamList; } function callNewAPI($apiURL, $requestParamList) { $jsonResponse = ""; $responseParamList = array(); $JsonData =json_encode($requestParamList); $postData = 'JsonData='.urlencode($JsonData); $ch = curl_init($apiURL); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($postData)) ); $jsonResponse = curl_exec($ch); $responseParamList = json_decode($jsonResponse,true); return $responseParamList; } function getRefundChecksumFromArray($arrayList, $key, $sort=1) { if ($sort != 0) { ksort($arrayList); } $str = getRefundArray2Str($arrayList); $salt = generateSalt_e(4); $finalString = $str . "|" . $salt; $hash = hash("sha256", $finalString); $hashString = $hash . $salt; $checksum = encrypt_e($hashString, $key); return $checksum; } function getRefundArray2Str($arrayList) { $findmepipe = '|'; $paramStr = ""; $flag = 1; foreach ($arrayList as $key => $value) { $pospipe = strpos($value, $findmepipe); if ($pospipe !== false) { continue; } if ($flag) { $paramStr .= checkString_e($value); $flag = 0; } else { $paramStr .= "|" . checkString_e($value); } } return $paramStr; } function callRefundAPI($refundApiURL, $requestParamList) { $jsonResponse = ""; $responseParamList = array(); $JsonData =json_encode($requestParamList); $postData = 'JsonData='.urlencode($JsonData); $ch = curl_init($apiURL); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $refundApiURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = array(); $headers[] = 'Content-Type: application/json'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $jsonResponse = curl_exec($ch); $responseParamList = json_decode($jsonResponse,true); return $responseParamList; } function pgRedirect($param){ header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); if(!empty($param)){ $checkSum = ""; $paramList = array(); // Create an array having all required parameters for creating checksum. $paramList["MID"] = $param['mid']; $paramList["ORDER_ID"] = $param["order_id"]; $paramList["CUST_ID"] = $param["cust_id"]; $paramList["INDUSTRY_TYPE_ID"] = $param['industry_type_id']; $paramList["CHANNEL_ID"] = $param['channel_id']; $paramList["TXN_AMOUNT"] = $param["txn_amount"]; $paramList["WEBSITE"] = $param['mwebsite']; $paramList["CALLBACK_URL"] = $param['callback']; /*$paramList["MSISDN"] = $MSISDN; //Mobile number of customer $paramList["EMAIL"] = $EMAIL; //Email ID of customer $paramList["VERIFIED_BY"] = "EMAIL"; // $paramList["IS_USER_VERIFIED"] = "YES"; // */ //print_obj($paramList);die; //Here checksum string will return by getChecksumFromArray() function. $checkSum = getChecksumFromArray($paramList,$param['mkey']); //print_obj($checkSum);die; ?> <center><h1>Please do not refresh this page...</h1></center> <form method="post" action="<?php echo $param['txn_url']; ?>" name="f1" id="f1"> <?php foreach($paramList as $name => $value) { echo '<input type="hidden" name="'. $name .'" value="' . $value . '" id="'. $name .'">'; } ?> <input type="hidden" name="CHECKSUMHASH" id="CHECKSUMHASH" value="<?php echo $checkSum; ?>"> </form> <?php }else{ return 'Prameters are empty'; } } function pgResponse($param){ // header("Pragma: no-cache"); // header("Cache-Control: no-cache"); // header("Expires: 0"); //return $param;die; if(!empty($param)){ $paytmChecksum = ""; $paramList = array(); $isValidChecksum = "FALSE"; // // In Test Page, we are taking parameters from POST request. In actual implementation these can be collected from session or DB. // $ORDER_ID = $_POST["ORDERID"]; // // Create an array having all required parameters for status query. // $requestParamList = array("MID" => $param['mid'] , "ORDERID" => $ORDER_ID); // $StatusCheckSum = getChecksumFromArray($requestParamList,$param['mkey']); // $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; // // Call the PG's getTxnStatusNew() function for verifying the transaction status. // $responseParamList = getTxnStatusNew($requestParamList); // return $responseParamList; $paramList = $_POST; $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg //Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application’s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc. $isValidChecksum = verifychecksum_e($paramList, $param['mkey'], $paytmChecksum); //will return TRUE or FALSE string. if($isValidChecksum == "TRUE"){ if ($_POST["STATUS"] == "TXN_SUCCESS"){ if (isset($_POST["ORDERID"]) && $_POST["ORDERID"] != ""){ // In Test Page, we are taking parameters from POST request. In actual implementation these can be collected from session or DB. $ORDER_ID = $_POST["ORDERID"]; // Create an array having all required parameters for status query. $requestParamList = array("MID" => $param['mid'] , "ORDERID" => $ORDER_ID); $StatusCheckSum = getChecksumFromArray($requestParamList,$param['mkey']); $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; // Call the PG's getTxnStatusNew() function for verifying the transaction status. $responseParamList = getTxnStatusNew($requestParamList,$param['paytm_status_query_new_url']); if (isset($responseParamList) && count($responseParamList)>0 ){ $return=$responseParamList; }else{ $return='Paytm Response error'; } }else{ $return='No Order ID Found'; } }else{ $return='Transaction Failed'; } }else{ $return='Checksum mismatched'; } }else{ $return='Parameter is empty'; } return $return; }