By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,652 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,652 IT Pros & Developers. It's quick & easy.

how to use $_REQUEST to get data from CCAVENUES

P: 2
Dear All I have shopping cart of ccavenues and I have got the success to send my database values to ccavenues shopping cart and that work very perfectly and user is able to pay the success ful payment but...

I am not able to figure out how can i get the success / failer message of shopping cart to my database.

Means I want to save the successfull entry to my website sql database that .

IF payment is successfull got to account page of my site
}
else got to login.php

I am pasting the code there kindly help me out please

mypayment page which is sending value to cart. normally they call it checkout.php but i have kept the name payment.php


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.                         include('usercheker.php'); // It to check user is logined or not.
  3.             $rs=mysql_query("Select * from user_info where ID=$usercci");
  4.             while($row1=mysql_fetch_array($rs))
  5.                 {
  6.                     $dob=$row1['DOB'];
  7.                     $country=$row1['COUNTRY'];
  8.                     $pid=$row1['ID'];        
  9.                     $plan=$row1['PLAN_AMT'];            
  10.                     $nm=$row1['NAME'];
  11.                     $m_tng=$row1['M_TNG'];
  12.                     $img=$row1['IMAGE'];
  13.                     $email=$row1['EMAIL'];
  14.                 }        
  15.                 require("libfuncs.php");
  16.  
  17.     $Merchant_Id = "M_web225514_s555" ;//This id(also User Id)  available at "Generate Working Key" of "Settings & Options" 
  18.     $Amount = "$plan" ;//your script should substitute the amount in the quotes provided here
  19.     $Order_Id = "$vvv" ;//your script should substitute the order description in the quotes provided here
  20.     $Redirect_Url = "http:/mydomain.com/success.php" ;//your redirect URL where your customer will be redirected after authorisation from CCAvenue
  21.  
  22.     $WorkingKey = "7m4xcvxcvxddddda6ls5"  ;//put in the 32 bit alphanumeric key in the quotes provided here.Please note that get this key ,login to your CCAvenue merchant account and visit the "Generate Working Key" section at the "Settings & Options" page. 
  23.     $Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);
  24. ?>
  25.  
  26.             <form method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">
  27.     <input type=hidden name=Merchant_Id value="<?php echo $Merchant_Id; ?>">
  28.     <input type=hidden name=Amount value="<?php echo $plan; ?>">
  29.     <input type=hidden name=Order_Id value="<?php echo $vvv; ?>">
  30.     <input type=hidden name=Redirect_Url value="<?php echo $Redirect_Url; ?>">
  31.     <input type=hidden name=Checksum value="<?php echo $Checksum; ?>">
  32.     <input type="hidden" name="billing_cust_name" value="<?php echo $nm; ?>"> 
  33.     <input type="hidden" name="billing_cust_address" value="<?php echo $city; ?>"> 
  34.     <input type="hidden" name="billing_cust_country" value="<?php echo $country; ?>"> 
  35.     <input type="hidden" name="billing_cust_state" value="<?php echo $state; ?>"> 
  36.     <input type="hidden" name="billing_zip" value="<?php echo $billing_zip; ?>"> 
  37.     <input type="hidden" name="billing_cust_tel" value="<?php echo $mobile; ?>"> 
  38.     <input type="hidden" name="billing_cust_email" value="<?php echo $email; ?>"> 
  39.     <input type="hidden" name="delivery_cust_name" value="<?php echo $nm; ?>"> 
  40.     <input type="hidden" name="delivery_cust_address" value="<?php echo $city; ?>"> 
  41.     <input type="hidden" name="delivery_cust_country" value="<?php echo $country; ?>"> 
  42.     <input type="hidden" name="delivery_cust_state" value="<?php echo $state; ?>"> 
  43.     <input type="hidden" name="delivery_cust_tel" value="<?php echo $mobile; ?>"> 
  44.     <input type="hidden" name="delivery_cust_notes" value="<?php echo $delivery_cust_notes; ?>"> 
  45.     <input type="hidden" name="Merchant_Param" value="<?php echo $Merchant_Param; ?>"> 
  46.     <input type="hidden" name="billing_cust_city" value="<?php echo $city; ?>"> 
  47.     <input type="hidden" name="billing_zip_code" value="<?php echo $city; ?>"> 
  48.     <input type="hidden" name="delivery_cust_city" value="<?php echo $city; ?>"> 
  49.     <input type="hidden" name="delivery_zip_code" value="<?php echo  $mobile; ?>"> 
  50.     <INPUT TYPE="submit" value="submit">
  51.     </form>

libfuncs.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
  3. {
  4.     $str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
  5.     $adler = 1;
  6.     $adler = adler32($adler,$str);
  7.     return $adler;
  8. }
  9.  
  10. function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
  11. {
  12.     $str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
  13.     $adler = 1;
  14.     $adler = adler32($adler,$str);
  15.  
  16.     if($adler == $CheckSum)
  17.         return "true" ;
  18.     else
  19.         return "false" ;
  20. }
  21.  
  22. function adler32($adler , $str)
  23. {
  24.     $BASE =  65521 ;
  25.  
  26.     $s1 = $adler & 0xffff ;
  27.     $s2 = ($adler >> 16) & 0xffff;
  28.     for($i = 0 ; $i < strlen($str) ; $i++)
  29.     {
  30.         $s1 = ($s1 + Ord($str[$i])) % $BASE ;
  31.         $s2 = ($s2 + $s1) % $BASE ;
  32.             //echo "s1 : $s1 <BR> s2 : $s2 <BR>";
  33.  
  34.     }
  35.     return leftshift($s2 , 16) + $s1;
  36. }
  37.  
  38. function leftshift($str , $num)
  39. {
  40.  
  41.     $str = DecBin($str);
  42.  
  43.     for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
  44.         $str = "0".$str ;
  45.  
  46.     for($i = 0 ; $i < $num ; $i++) 
  47.     {
  48.         $str = $str."0";
  49.         $str = substr($str , 1 ) ;
  50.         //echo "str : $str <BR>";
  51.     }
  52.     return cdec($str) ;
  53. }
  54.  
  55. function cdec($num)
  56. {
  57.  
  58.     for ($n = 0 ; $n < strlen($num) ; $n++)
  59.     {
  60.        $temp = $num[$n] ;
  61.        $dec =  $dec + $temp*pow(2 , strlen($num) - $n - 1);
  62.     }
  63.  
  64.     return $dec;
  65. }
  66. ?>


Redirect .php
Expand|Select|Wrap|Line Numbers
  1. <? require("libfuncs.php");
  2.  
  3. /*
  4.  
  5.     This is the sample RedirectURL PHP script. It can be directly used for integration with CCAvenue if your application is developed in PHP. You need to simply change the variables to match your variables as well as insert routines for handling a successful or unsuccessful transaction.
  6.  
  7.     return values i.e the parameters namely Merchant_Id,Order_Id,Amount,AuthDesc,Checksum,billing_cust_name,billing_cust_address,billing_cust_country,billing_cust_tel,billing_cust_email,delivery_cust_name,delivery_cust_address,delivery_cust_tel,billing_cust_notes,Merchant_Param POSTED to this page by CCAvenue. 
  8.  
  9. */
  10.  
  11.     $WorkingKey = "7m4fssiby9aqxa6ls5" ; //put in the 32 bit working key in the quotes provided here
  12.     $Merchant_Id= $_REQUEST[''];
  13.     $Amount= $_REQUEST[''];
  14.     $Order_Id= $_REQUEST[''];
  15.     $Merchant_Param= $_REQUEST['Merchant_Param'];
  16.     $Checksum= $_REQUEST['Checksum'];
  17.     $AuthDesc=$_REQUEST['AuthDesc'];
  18.  
  19.     $Checksum = verifyChecksum($Merchant_Id, $Order_Id , $Amount,$AuthDesc,$Checksum,$WorkingKey);
  20.  
  21.  
  22.     if($Checksum=="true" && $AuthDesc=="Y")
  23.     {
  24.         echo "<br>Thank you for shopping with us. Your credit card has been charged and your transaction is successful. We will be shipping your order to you soon.";
  25.  
  26.         //Here you need to put in the routines for a successful 
  27.         //transaction such as sending an email to customer,
  28.         //setting database status, informing logistics etc etc
  29.     }
  30.     else if($Checksum=="true" && $AuthDesc=="B")
  31.     {
  32.         echo "<br>Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";
  33.  
  34.         //Here you need to put in the routines/e-mail for a  "Batch Processing" order
  35.         //This is only if payment for this transaction has been made by an American Express Card
  36.         //since American Express authorisation status is available only after 5-6 hours by mail from ccavenue and at the "View Pending Orders"
  37.     }
  38.     else if($Checksum=="true" && $AuthDesc=="N")
  39.     {
  40.         echo "<br>Thank you for shopping with us.However,the transaction has been declined.";
  41.  
  42.         //Here you need to put in the routines for a failed
  43.         //transaction such as sending an email to customer
  44.         //setting database status etc etc
  45.     }
  46.     else
  47.     {
  48.         echo "<br>Security Error. Illegal access detected";
  49.  
  50.         //Here you need to simply ignore this and dont need
  51.         //to perform any operation in this condition
  52.     }
  53. ?>
Sep 30 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.