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
- <?php
- include('usercheker.php'); // It to check user is logined or not.
- $rs=mysql_query("Select * from user_info where ID=$usercci");
- while($row1=mysql_fetch_array($rs))
- {
- $dob=$row1['DOB'];
- $country=$row1['COUNTRY'];
- $pid=$row1['ID'];
- $plan=$row1['PLAN_AMT'];
- $nm=$row1['NAME'];
- $m_tng=$row1['M_TNG'];
- $img=$row1['IMAGE'];
- $email=$row1['EMAIL'];
- }
- require("libfuncs.php");
- $Merchant_Id = "M_web225514_s555" ;//This id(also User Id) available at "Generate Working Key" of "Settings & Options"
- $Amount = "$plan" ;//your script should substitute the amount in the quotes provided here
- $Order_Id = "$vvv" ;//your script should substitute the order description in the quotes provided here
- $Redirect_Url = "http:/mydomain.com/success.php" ;//your redirect URL where your customer will be redirected after authorisation from CCAvenue
- $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.
- $Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);
- ?>
- <form method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">
- <input type=hidden name=Merchant_Id value="<?php echo $Merchant_Id; ?>">
- <input type=hidden name=Amount value="<?php echo $plan; ?>">
- <input type=hidden name=Order_Id value="<?php echo $vvv; ?>">
- <input type=hidden name=Redirect_Url value="<?php echo $Redirect_Url; ?>">
- <input type=hidden name=Checksum value="<?php echo $Checksum; ?>">
- <input type="hidden" name="billing_cust_name" value="<?php echo $nm; ?>">
- <input type="hidden" name="billing_cust_address" value="<?php echo $city; ?>">
- <input type="hidden" name="billing_cust_country" value="<?php echo $country; ?>">
- <input type="hidden" name="billing_cust_state" value="<?php echo $state; ?>">
- <input type="hidden" name="billing_zip" value="<?php echo $billing_zip; ?>">
- <input type="hidden" name="billing_cust_tel" value="<?php echo $mobile; ?>">
- <input type="hidden" name="billing_cust_email" value="<?php echo $email; ?>">
- <input type="hidden" name="delivery_cust_name" value="<?php echo $nm; ?>">
- <input type="hidden" name="delivery_cust_address" value="<?php echo $city; ?>">
- <input type="hidden" name="delivery_cust_country" value="<?php echo $country; ?>">
- <input type="hidden" name="delivery_cust_state" value="<?php echo $state; ?>">
- <input type="hidden" name="delivery_cust_tel" value="<?php echo $mobile; ?>">
- <input type="hidden" name="delivery_cust_notes" value="<?php echo $delivery_cust_notes; ?>">
- <input type="hidden" name="Merchant_Param" value="<?php echo $Merchant_Param; ?>">
- <input type="hidden" name="billing_cust_city" value="<?php echo $city; ?>">
- <input type="hidden" name="billing_zip_code" value="<?php echo $city; ?>">
- <input type="hidden" name="delivery_cust_city" value="<?php echo $city; ?>">
- <input type="hidden" name="delivery_zip_code" value="<?php echo $mobile; ?>">
- <INPUT TYPE="submit" value="submit">
- </form>
libfuncs.php
Expand|Select|Wrap|Line Numbers
- <?php
- function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
- {
- $str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
- $adler = 1;
- $adler = adler32($adler,$str);
- return $adler;
- }
- function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
- {
- $str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
- $adler = 1;
- $adler = adler32($adler,$str);
- if($adler == $CheckSum)
- return "true" ;
- else
- return "false" ;
- }
- function adler32($adler , $str)
- {
- $BASE = 65521 ;
- $s1 = $adler & 0xffff ;
- $s2 = ($adler >> 16) & 0xffff;
- for($i = 0 ; $i < strlen($str) ; $i++)
- {
- $s1 = ($s1 + Ord($str[$i])) % $BASE ;
- $s2 = ($s2 + $s1) % $BASE ;
- //echo "s1 : $s1 <BR> s2 : $s2 <BR>";
- }
- return leftshift($s2 , 16) + $s1;
- }
- function leftshift($str , $num)
- {
- $str = DecBin($str);
- for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
- $str = "0".$str ;
- for($i = 0 ; $i < $num ; $i++)
- {
- $str = $str."0";
- $str = substr($str , 1 ) ;
- //echo "str : $str <BR>";
- }
- return cdec($str) ;
- }
- function cdec($num)
- {
- for ($n = 0 ; $n < strlen($num) ; $n++)
- {
- $temp = $num[$n] ;
- $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
- }
- return $dec;
- }
- ?>
Redirect .php
Expand|Select|Wrap|Line Numbers
- <? require("libfuncs.php");
- /*
- 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.
- 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.
- */
- $WorkingKey = "7m4fssiby9aqxa6ls5" ; //put in the 32 bit working key in the quotes provided here
- $Merchant_Id= $_REQUEST[''];
- $Amount= $_REQUEST[''];
- $Order_Id= $_REQUEST[''];
- $Merchant_Param= $_REQUEST['Merchant_Param'];
- $Checksum= $_REQUEST['Checksum'];
- $AuthDesc=$_REQUEST['AuthDesc'];
- $Checksum = verifyChecksum($Merchant_Id, $Order_Id , $Amount,$AuthDesc,$Checksum,$WorkingKey);
- if($Checksum=="true" && $AuthDesc=="Y")
- {
- 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.";
- //Here you need to put in the routines for a successful
- //transaction such as sending an email to customer,
- //setting database status, informing logistics etc etc
- }
- else if($Checksum=="true" && $AuthDesc=="B")
- {
- echo "<br>Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";
- //Here you need to put in the routines/e-mail for a "Batch Processing" order
- //This is only if payment for this transaction has been made by an American Express Card
- //since American Express authorisation status is available only after 5-6 hours by mail from ccavenue and at the "View Pending Orders"
- }
- else if($Checksum=="true" && $AuthDesc=="N")
- {
- echo "<br>Thank you for shopping with us.However,the transaction has been declined.";
- //Here you need to put in the routines for a failed
- //transaction such as sending an email to customer
- //setting database status etc etc
- }
- else
- {
- echo "<br>Security Error. Illegal access detected";
- //Here you need to simply ignore this and dont need
- //to perform any operation in this condition
- }
- ?>