ccavenue api integration with codeigniter
Here you can get the documentation.
http://world.ccavenue.com/downloads/CCAVenueWorldIntegrationManual.pdf
And you can get the code from the ccavenue account. just ask for ccavenue account holder to send you the code zip folder which contains 3 languages code and you have to go with php folder.
Ask for the following
Integration Kit:
Login to ccavenue account and click on the link to download the kit. you will find this within the "How to set up your ccavenue account?".Working Key: Go to settings and option links in top menu and click on Generate Working key link. And select activate option.
Merchant Id:You will see it in same page where working key is created.
After getting the code you just need to use that code in codeigniter's way.
You can also have a look on this code.
http://technoread.net/webdesign/payment-gateways/item/238-ccavenue-payment-integration-php
**Here is your view file subscription.php** <html> <head> <script> window.onload = function() { var d = new Date().getTime(); document.getElementById("tid").value = d; }; </script> </head> <body> <form method="POST" name="customerData" action="<?php echo base_url('ws_user/ccavRequestHandler'); ?>"> <input type="hidden" name="tid" id="tid" /> <input type="hidden" name="merchant_id" value="your merchent id"/> <input type="hidden" name="payment_option" value="OPTNBK"> <input type="hidden" name="order_id" value="123654789"/> <input type="hidden" name="merchant_param1" value="your custom value"/> <input type="hidden" name="merchant_param2" value="<?php echo $userId; ?>"/> <input type="hidden" name="amount" value="<?php echo $amount; ?>"/> <input type="hidden" name="currency" value="INR"/> <input type="hidden" name="redirect_url" value="<?php echo base_url('webservice/payDone');?>"/> <input type="hidden" name="cancel_url" value="<?php echo base_url('webservice/cancelPayment');?>"/> <input type="hidden" name="billing_name" value="<?php echo $addressData[0]->name;?>"/> <input type="hidden" name="billing_address" value="<?php echo $addressData[0]->AddressLine1 . ' '. $addressData[0]->Addressline2;?>"/> <input type="hidden" name="billing_city" value="<?php echo $addressData[0]->city_name;?>"/> <input type="hidden" name="billing_state" value="<?php echo $addressData[0]->state_name;?>"/> <input type="hidden" name="billing_zip" value="<?php echo $addressData[0]->Zipcode;?>"/> <input type="hidden" name="billing_country" value="<?php echo $addressData[0]->country_name;?>"/> <input type="hidden" name="billing_tel" value="<?php echo $addressData[0]->contact;?>"/> </form> <script language='javascript'>document.customerData.submit();</script> </body></html>
Here is your CI FUNCTION
public function ccavRequestHandler() { $this->load->view('ccavRequestHandler'); }
Here is your file ccavRequestHandler.php
<html> <body> <?php include('Crypto.php')?> <?php $merchant_data=''; $working_key='your working key';//Shared by CCAVENUES $access_code='your access code';//Shared by CCAVENUES foreach ($_POST as $key => $value) { $merchant_data.=$key.'='.urlencode($value).'&'; } $encrypted_data=encrypt($merchant_data,$working_key); ?> <form method="post" name="redirect" action="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction"> <?php echo "<input type=hidden name=encRequest value=$encrypted_data>"; echo "<input type=hidden name=access_code value=$access_code>";?> </form> <script language='javascript'>document.redirect.submit()</script> </body> </html>
Here is your success URL
public function payDone() { $encResp=$_REQUEST['encResp']; $working_key='YOURKEY'; $decryptValues=explode('&',$this->common->decrypt($encResp,$working_key)); $dataSize=sizeof($decryptValues); /*CODE FOR GET YOUR VERIABLE WHEN REDIRECT ON YOUR URL */ for($i = 0; $i < $dataSize; $i++) { $information=explode('=',$decryptValues[$i]); if($information[0] == 'merchant_param1') { $address = $information[1]; } if($information[0] == 'merchant_param2') { $userid = $information[1]; } if($information[0] == 'order_status') { $order_status = $information[1]; } } /*CHECK PAYMENT IS SUCCESS OR FAIL */ if($order_status == 'Success') { /* DO what ever you want after successful payment */ Redirect('webservice/paymentSuccess'); } else { /* do whatever you want after failure */ redirect('webservice/paymentFail'); } }