Sunteți pe pagina 1din 4

PHP Script for Integration of CCAvenue Payment Gateway opensourceprogrammer.

in
Integration of CCAVENUE Payment Cart in Your Shopping Section CCavenue is most popular Payment gateway for online Shopping in india. It provide payment through using International credit card your Bank (who have bond with CCavenue) online Account or using its debit card(ATM card). It is one of the most secure place for given your money to online shop. For Integrate it with your website you should have CCavenue account and they give you a merchant id and a unique key for your site that is most important for money transaction. Php Functions Require TO Validate Require Value for CCAvenue Payment. PHP File :- ccavenueValidate.php ? 01 02 function getCheckSum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey) 03 { $str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey"; 04 $adler = 1; 05 $adler = adler32($adler,$str); 06 return $adler; 07 } 08 09 function verifyCheckSum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey 10 11) { 12 $str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey"; 13 $adler = 1; $adler = adler32($adler,$str); 14 15 if($adler == $CheckSum) 16 return "true" ; 17 else 18 return "false" ; 19 } 20 function adler32($adler , $str) 21 { 22 $BASE = 65521 ; 23 24 $s1 = $adler & 0xffff ;
<?php

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58?> 59 60 61 62 63 64 65 66 67

$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; }

Processing Page Code CCAvenue Passing Parameter That Require for Complete the Shopping

In this page data comes from checkout form of shopping cart collect and validate according CCAcenue rules and arrange in given format and send it CCAenue sever for payment Processing. ?
<?php include(ccavenueValidate.php); $ccavenuemerchantId= "";//This id(also User Id) available at "Generate 01 Working Key" of "Settings & Options" 02 $Amount = $orderdata[5];//your script should substitute the amount in 03the quotes provided here 04 $orderId= $orderdata[0];;//your script should substitute the order 05description in the quotes provided here $WorkingKey = "";//Given to merchant by ccavenue 06 $returnUrl ="http://www.example.com/shopping.php"; //url of your 07successpage 08 $Checksum = 09getCheckSum($Merchant_Id,$Amount,$orderId,$Redirect_Url,$WorkingKey); // 10Validate All value ?>

11 12 <p align="center" style="font-family:Calibri; font13size:24px;color:#3670A7;">Processing to CCAvenue..............</p> 14 15<form id="submittoserver" method="post" 16action="https://www.ccavenue.com/shopzone/cc_details.jsp"> <input type=hidden name=Merchant_Id value="<?php echo $ 17 ccavenuemerchantId; ?>"> 18 <input type="hidden" name="Amount" value="<?php echo $Amount; ?>"> 19 <input type="hidden" name="Order_Id" value="<?php echo $ orderId; ?>"> 20 <input type="hidden" name="Redirect_Url" value="<?php echo $ returnUrl; 21?>"> <input type="hidden" name="Checksum" value="<?php echo $Checksum; ?>"> 22 <input type="hidden" name="billing_cust_name" value="<?= $orderdata[7].' 23'.$orderdata[8];?>"> <!--Pass Customer Full Name --> 24 <input type="hidden" name="billing_cust_address" value="<?= 25$orderdata[9].' '.$orderdata[10];?>"><!--Pass Customer Full Address--> <input type="hidden" name="billing_cust_country" value="<?= 26 $orderdata[15];?>"> <!--Pass Customer Country --> 27 <input type="hidden" name="billing_cust_state" value="<?= 28$orderdata[14];?>"><!--Pass Customer State --> 29 <input type="hidden" name="billing_cust_city" value="<?= 30$orderdata[13];?>"> <!--Pass Customer City --> <input type="hidden" name="billing_zip" value="<?= $orderdata[16];?>"> 31 <!--Pass Customer Zip Code--> 32 <input type="hidden" name="billing_cust_tel" value="<?= 33$orderdata[11];?>"> <!--Pass Customer Phone No--> <input type="hidden" name="billing_cust_email" value="<?= 34 $orderdata[12];?>"> <!--Pass Customer Email address--> 35 <input type="hidden" name="delivery_cust_name" 36$orderdata[7].' '.$orderdata[8];?>"> <!--Pass Samevalue="<?=other detail or other 37fill by customer--> 38 <input type="hidden" name="delivery_cust_address" value="<?=
$orderdata[9].' '.$orderdata[10];?>"> <input type="hidden" name="delivery_cust_country" value="<?=

$orderdata[15];?>"> <input type="hidden" $orderdata[14];?>"> <input type="hidden" $orderdata[11];?>"> <input type="hidden" <input type="hidden" <input type="hidden" $orderdata[16];?>"> <input type="hidden" $orderdata[13];?>"> <input type="hidden" $orderdata[16];?>"> </form>

name="delivery_cust_state" value="<?= name="delivery_cust_tel" value="<?= name="delivery_cust_notes" value=""> name="Merchant_Param" value=""> name="billing_zip_code" value="<?= name="delivery_cust_city" value="<?= name="delivery_zip_code" value="<?=

S-ar putea să vă placă și