Cashfree - this integration is deprecated, please use latest integration or reach out to the merchant

 https://www.cashfree.com/checkout/post/submit


Solution: This method is not allowed, this method is outdated. If you are integrating cashfree gateway with this method then you will also show similar error, you will have to integrate the gateway with a new method.

Check which is the latest version currently running on Cashfree's website, for this click on the given link: https://docs.cashfree.com/reference/release-notes.




This old script : - 
<!DOCTYPE html>
<html>
<head>
  <title>Cashfree - Payment Gateway</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body onload="document.frm1.submit()">


<?php 
require_once('../database/config.php');
require_once('../cashfree/conn.php');

$orderId = $_POST['ORDER_ID'];
$orderAmount = $_POST['TXN_AMOUNT'];

$orderCurrency = 'INR';
$orderNote = 'Payment Add by '.$_POST['CUST_ID'];
$customerName = $_POST['CUST_ID'];
$customerPhone = $_POST['MSISDN'];
$customerEmail = $_POST['EMAIL'];

extract($_POST);
  $postData = array( 
  "appId" => $appId, 
  "orderId" => $orderId, 
  "orderAmount" => $orderAmount, 
  "orderCurrency" => $orderCurrency, 
  "orderNote" => $orderNote, 
  "customerName" => $customerName, 
  "customerPhone" => $customerPhone, 
  "customerEmail" => $customerEmail,
  "returnUrl" => $returnUrl, 
  "notifyUrl" => $notifyUrl,
);
// print_r($postData);die;
ksort($postData);
$signatureData = "";
foreach ($postData as $key => $value){
    $signatureData .= $key.$value;
}
$signature = hash_hmac('sha256', $signatureData, $secretKey,true);
$signature = base64_encode($signature);

if ($mode == "TEST") {
  $url = "https://test.cashfree.com/billpay/checkout/post/submit";
} else {
  $url = "https://www.cashfree.com/checkout/post/submit";
}

?>

<body>
<div style="text-align: center;
    font-family: sans-serif;">
    <br/>
    <br/><br/>
    <h1>Please wait we are redirecting you to payment gateway..</h1>
        <h4>Don't press refresh/back button</h4>
        <center><img src="../cashfree/Spinner.gif" height="100"></center></div>
    <br/>
</div>
  <form action="<?php echo $url; ?>" name="frm1" method="post">
<table border="1">
<tbody>
<input type="hidden" name="signature" value='<?php echo $signature; ?>'/>
      <input type="hidden" name="orderNote" value='<?php echo $orderNote; ?>'/>
      <input type="hidden" name="orderCurrency" value='<?php echo $orderCurrency; ?>'/>
      <input type="hidden" name="customerName" value='<?php echo $customerName; ?>'/>
      <input type="hidden" name="customerEmail" value='<?php echo $customerEmail; ?>'/>
      <input type="hidden" name="customerPhone" value='<?php echo $customerPhone; ?>'/>
      <input type="hidden" name="orderAmount" value='<?php echo $orderAmount; ?>'/>
      <input type ="hidden" name="notifyUrl" value='<?php echo $notifyUrl; ?>'/>
      <input type ="hidden" name="returnUrl" value='<?php echo $returnUrl; ?>'/>
      <input type="hidden" name="appId" value='<?php echo $appId; ?>'/>
      <input type="hidden" name="orderId" value='<?php echo $orderId; ?>'/>
</tbody>
</table>
<script type="b38a73a8274a71b6f4f22925-text/javascript">
document.f1.submit();
</script>
</form>
<script src="/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="b38a73a8274a71b6f4f22925-|49" defer=""></script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"748ae7a61cbd8a24","version":"2022.8.1","r":1,"token":"776747cc12a0498d892340139df76c4d","si":100}' crossorigin="anonymous"></script>
</body>
</html>








Cashfree Gateway Integrate New php code Script :-

<!DOCTYPE html>
<html>
<head>
  <title>Cashfree - Payment Gateway</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body onload="document.frm1.submit()">


<?php 
require_once('conn.php');

$orderId = $_POST['ORDER_ID'];
$orderAmount = $_POST['TXN_AMOUNT'];
$orderCurrency = 'INR';
$orderNote = 'Payment Add by ' . $_POST['MSISDN'];
$customerName = $_POST['CUST_ID'];
$customerPhone = $_POST['MSISDN'];
$customerEmail = $_POST['EMAIL'];
$rc_method =  $_POST['rc_method'];
$postData = array(
  "order_id" => $orderId,
  "order_amount" => $orderAmount,
  "order_currency" => $orderCurrency,
  "order_note" => $orderNote,
  "customer_details" => array(
    "customer_id" => 'customer_' . uniqid(),
    "customer_name" => $customerName,
    "customer_email" => $customerEmail,
    "customer_phone" => $customerPhone
  ),
  "order_meta" => array(
    "return_url" => $returnUrl,
"payment_methods" => $rc_method
  )
);

// Your code to handle $postData goes here

if($_SERVER['REQUEST_METHOD']=='POST'){ 
if($mode=="TEST"){
 $livemode = "https://sandbox.cashfree.com/pg/orders";
}else{
 $livemode = "https://api.cashfree.com/pg/orders";
}
    $curl = curl_init();
    
    curl_setopt_array($curl, [
      CURLOPT_URL => $livemode,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => json_encode($postData),
      CURLOPT_HTTPHEADER => [
        "accept: application/json",
        "content-type: application/json",
        "x-api-version: 2023-08-01",
        "x-client-id: $appId",
        "x-client-secret: $secretKey"
      ],
    ]);
    
      echo $response = curl_exec($curl);
    curl_close($curl);

exit();
        $payment_link = json_decode($response, true);
        if(isset($payment_link['payment_session_id'])){
?>
<!DOCTYPE html>
<html lang="en">
  <head>
  <title>Cashfree - Payment Gateway</title>
    <script src="https://sdk.cashfree.com/js/v3/cashfree.js"></script>
  </head>
  <body>
   <div style="text-align: center;
    font-family: sans-serif;">
    <br/>
    <br/><br/>
    <h1>Please wait we are redirecting you to payment gateway..</h1>
        <h4>Don't press refresh/back button</h4>
        <center><img src="../cashfree/Spinner.gif" height="100"></center></div>
  </body>
  <script>
    document.addEventListener("DOMContentLoaded", () => {
      const cashfree = Cashfree({
        mode: "sandbox" // or production
      });

      // Trigger the checkout process automatically
      cashfree.checkout({
        paymentSessionId: "<?php echo $payment_link['payment_session_id']; ?>"
      });
    });
  </script>
</html>

 <?php
        }else {
            echo '<script>alert("Access Denied or contact admin");
window.location.href="'.$walletUrl.'";
</script>';
        }

}else {
            echo '<script>alert("Access Denied or contact admin");
window.location.href="'.$walletUrl.'";
</script>';
        }

?>


Post a Comment

Previous Post Next Post