Thursday, September 26, 2013

Easy way to integration of ccavenue payment gateway using php

CCavenue is most popular Payment gateway for online Shopping. It provide payment through using International credit card as well using your Bank (who have bond with CCavenue) online Account or using it's 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.


Creat a validCCAvenueparam.php  for server side generate valid checksum param
----------------------------------------------------------------------------------------
<?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;
  }
  ?>
-------------------------------------------------------------------------------------------------------------------------------

Step -2
create cat page form cart.php


 <?php
    $Merchant_Id = "M_apa18528_18528";//This id(also User Id)  available at "Generate Working Key" of "Settings & Options" 
    $Amount = 900;;//your script should substitute the amount in the quotes provided here
    $Order_Id = 689663;//your script should substitute the order description in the quotes provided here
    $WorkingKey = "";//Note : if you empty the working value then CCavenue "return 
Error Code: 108
Error Description: Checksum+mismatch
because CCavenue security key providing to merchant . 

    $Redirect_Url ="http://www.englishleap.com/users/payment/";
    $Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value 
    ?>


<form action="https://www.ccavenue.com/shopzone/cc_details.jsp" method="post">
<!--<br/>Merchant_Id:
--><input type="hidden" value="<?php echo $Merchant_Id; ?>" name="Merchant_Id">
<!--<br/>Amount:
--><input type="hidden" value="<?php echo $Amount; ?>" name="Amount">
<!--<br/>Order_Id:
--><input type="hidden" value="<?php echo $Order_Id; ?>" name="Order_Id">
<!--<br/>Redirect_Url:
--><input type="hidden" value="<?php echo $Redirect_Url; ?>" name="Redirect_Url">
<!--<br/>Checksum:
--><input type="hidden" value="<?php echo $Checksum; ?>" name="Checksum">
<!--<br/>billing_cust_name:
--><input type="hidden" value="bp.nayak20000" name="billing_cust_name"> 
<!--<br/>billing_cust_address:
--><input type="hidden" value="" name="billing_cust_address"> 
<!--<br/>billing_cust_country:
--><input type="hidden" value="" name="billing_cust_country"> 
<!--<br/>billing_cust_state:
--><input type="hidden" value="" name="billing_cust_state"> 
<!--<br/>billing_zip:
--><input type="hidden" value="" name="billing_zip"> 
<!--<br/>billing_cust_tel:
--><input type="hidden" value="" name="billing_cust_tel"> 
<!--<br/>billing_cust_email:
--><input type="hidden" value="bp.nayak20000@gmail.com" name="billing_cust_email"> 
<!--<br/>delivery_cust_name:
--><input type="hidden" value="bp.nayak20000" name="delivery_cust_name"> 
<!--<br/>delivery_cust_address:
--><input type="hidden" value="" name="delivery_cust_address"> 
<!--<br/>delivery_cust_country:
--><input type="hidden" value="" name="delivery_cust_country"> 
<!--<br/>delivery_cust_state:
--><input type="hidden" value="" name="delivery_cust_state"> 
<!--<br/>delivery_cust_tel:
--><input type="hidden" value="" name="delivery_cust_tel"> 
<!--<br/>delivery_cust_notes:
--><input type="hidden" value="" name="delivery_cust_notes"> 
<!--<br/>Merchant_Param:
--><input type="hidden" value="" name="Merchant_Param"> 
<!--<br/>billing_cust_city:
--><input type="hidden" value="" name="billing_cust_city"> 
<!--<br/>billing_zip_code:
--><input type="hidden" value="" name="billing_zip_code"> 
<!--<br/>delivery_cust_city:
--><input type="hidden" value="" name="delivery_cust_city"> 
<!--<br/>delivery_zip_code:
--><input type="hidden" value="" name="delivery_zip_code"> 
<input type="submit" class="button-placeorder" value="Pay by CCavenue ">
</form>

41 comments:

  1. Gr8 help dude :) appreciated

    ReplyDelete
  2. Hello I m not getting anything in response please help me...however when some one make payment correctly with correct details payments is successfully deposited in account ..but how to check if payment is failed or success i m using bellow code for checking response please check it and help me to get out of this..

    ReplyDelete
  3. Hi Dear,

    you can chech your payment status by

    if($Checksum=="true" && $AuthDesc=="Y") {
    return 'success';
    }
    For more info visit the below url link:-

    http://subversion.assembla.com/svn/katalog/trunk/html/scripts/modules/payment/class.ccavenue.php

    ReplyDelete
    Replies
    1. Hi Dear,

      First of all thanks for this. But Still I m not getting anything in response. I m using this this code on my redirect url page .
      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.";

      }
      else if($Checksum=="true" && $AuthDesc=="Y")
      {
      echo "
      Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";

      }
      else if($Checksum=="true" && $AuthDesc=="Y")
      {
      echo "
      Thank you for shopping with us.However,the transaction has been declined.";

      }

      else
      {
      echo "
      Thank you for shopping with us.";

      }
      ?>


      Please Healp me to get out of this.

      Delete

    2. 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.";

      }
      else if($Checksum=="true" && $AuthDesc=="Y")
      {
      echo "
      Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";

      }
      else if($Checksum=="true" && $AuthDesc=="Y")
      {
      echo "
      Thank you for shopping with us.However,the transaction has been declined.";

      }

      else
      {
      echo "
      Thank you for shopping with us.";

      }

      ?>

      Delete
    3. Hi Dsear,
      You have to configure to get response from CCavnue step->follow this link
      http://stackoverflow.com/questions/20612483/cc-avenue-payment-gateway-not-return-value-in-to-redirect-url

      Delete
  4. I'm facing the same problem here. There is no response. I think it can,t find the redirecturl page.
    Please help

    ReplyDelete
  5. CCAvenue payment integration php
    Integrating CCavenue payment gateway is simple
    We need a merchant id and working for implementing payment gateway

    check link
    http://www.codingprogrammer.com/tutorialdemo/php-tutorial/ccavenue-payment-integration-php/

    ReplyDelete
    Replies
    1. where to add the account number of customer. I can't find the fields like accnt number and cvv fields in the form fields hidden....

      Delete
  6. 112 Don't worry... It happens to the best of us.

    Please provide any help for this.

    ReplyDelete
  7. Hi

    I am getting an error when i reached this url :-https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction

    Something went wrong while processing your request.
    Don't worry... It happens to the best of us.

    ReplyDelete
  8. Hi,
    Could you assist me in getting transaction id of ccavenue

    ReplyDelete
  9. OMG!!!! CC AVENUE INTEGRATION WAS VERY SIMPLE...
    1)log in to ccavenue account
    2)click on resources->integration kit
    3)You will be redirected to a page. then click on download integration kits.
    4)choose the appropriate platform like php or asp.net or python. download the kit.
    5)extract it and you willl find three folders,(you can choose any folder).
    let us suppose select custom checkout formkit folder.
    6)Open dataFrom_EMI.htm
    7)Open ccavRequestHandler.php and paste the access code, working key over that page and save the page.
    8)open ccavResponseHandler.php and paste the working key on that page and save the page.
    9) go to form page and type in your merchant id. then blindly scroll down and click on submit, without filling bank details or any stuff, click on submit. you will be redirected to payment gateway to fill choose the card number and cvv.etc....
    You willl understand what to do once you view that page....
    Hope that helps.......

    ReplyDelete
    Replies
    1. Thanks @Amardeep, its really helps me.

      Delete
    2. You are welcome... Good to hear that.

      Delete
    3. Thanks..

      Its Not Working Localhost??

      Delete
    4. Thanks for your post Amardeep. It is very helpfull to mee.

      Delete
  10. hi
    i downloaded the PHP kit and used non seamless and added the working key and access code. it shows error

    ReplyDelete
    Replies
    1. We will help you http://infotwistsolutions.blogspot.com/

      Delete
  11. please let me know ccavenue & paypal integrate same website (Joomla)

    ReplyDelete
  12. Hello Admin
    We exchange Backlink
    My Website is
    www.twinkyphone.com

    If intrusted Then Msg Me on WhatsApp to 7503583831

    ReplyDelete
  13. Error Code: 21002 currency: Required paramter missing

    Don't worry... It happens to the best of us.

    where to pass currency parameter please any one help.......Thanks

    ReplyDelete
  14. Given error


    Error Code: 94
    Error Description: Amount+Invalid

    how to solve.

    ReplyDelete
  15. Jain Technosoft has an expert team of PHP Programmers, which have good knowledge in Linux, Apache, MySQL, PHP (LAMP) and AJAX. We provide flexible, efficient and affordable PHP Application Development Services in the areas of dynamic web application development. Our PHP developers are proficient in developing web applications using Core PHP as well as experts in products like Joomla, WordPress, Drupal, Magento, Virtuemart and OsCommerce.

    Website Development Company in Bangalore | SEO Services in Bangalore

    ReplyDelete
  16. i used same code but did not successes.
    it redirect me to
    https://www.ccavenue.com/errorPages/Error.jsp?errorCode=0&processingFileName=ccavenue.txn.DoTransServlet&errorMessage=&cid=114381-689663

    ReplyDelete
  17. Best and to the point explanation in just 3 minutes.watch the video on the below link.

    https://www.youtube.com/watch?v=2V11Aih2luU

    ReplyDelete
  18. Am getting 403 or 10001 error for cc avenue integration on India currency with php. can any one send the code related encryption from UI or index end

    ReplyDelete
    Replies
    1. Hi Pravalika,
      Please follow below instruction . hope you will resolve your 10001 encryption error.
      OMG!!!! CC AVENUE INTEGRATION WAS VERY SIMPLE...
      1)log in to ccavenue account
      2)click on resources->integration kit
      3)You will be redirected to a page. then click on download integration kits.
      4)choose the appropriate platform like php or asp.net or python. download the kit.
      5)extract it and you willl find three folders,(you can choose any folder).
      let us suppose select custom checkout formkit folder.
      6)Open dataFrom_EMI.htm
      7)Open ccavRequestHandler.php and paste the access code, working key over that page and save the page.
      8)open ccavResponseHandler.php and paste the working key on that page and save the page.
      9) go to form page and type in your merchant id. then blindly scroll down and click on submit, without filling bank details or any stuff, click on submit. you will be redirected to payment gateway to fill choose the card number and cvv.etc....

      example page :
      http://www.freelancephpdevelopment.com/php-script-for-ccavenue-and-ccavenue-payment-gateway-integration-in-php/

      Delete
  19. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Ya i have done the total part well but getting the same error 10001. Is there any thing needed to connect from our end between the kit(using php non seemless kit) our code. We have just given direct link to checkout button i..e https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction. Can you please help me in that how to retrieve data of cart item which is selected.

      Delete
  20. CC Avenue Payment working on 000Webhost?

    ReplyDelete
  21. I am getting this error through my website. Any clue?

    -------------------

    This site can’t be reached

    The webpage at https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction might be temporarily down or it may have moved permanently to a new web address.
    ERR_CONNECTION_ABORTED

    ReplyDelete
  22. Hello Dear sir

    I like your blog very well, I want to say thank you for giving so good information.
    I have a website duspay.com. We provide payment gateway
    Payment Gateway | Duspay

    ReplyDelete
  23. Hello,

    Please help me i want to send more than 5 custom perameters in my form but ccavenue give me only 5 custom fields (merchant_param5) if i send our custom veriable with delimiter (|) its showing on ccavenue page.so, what is right way to do this

    ReplyDelete