yogidegr8 Posted February 5, 2004 Share Posted February 5, 2004 I surched the forum but am not able to find solution. I installed the credit card from www.ccavenue.com to my site successfully. But when a buyer buys and pay through it, I am getting the payment correctly, but the database is not getting updated therefore I am not being to know what the customer have ordered. Can anyone suggest what shall I add and where so the order is updated in database just before the buyer proceeds to payment gateway. My payment module file cavenue.php is mentioned below.: / catalogue / includes / modules / payment / <?php/* $Id: cavenue.php,v 1.25 2002/11/01 05:04:31 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License */ class cavenue { var $code, $title, $description, $enabled; // class constructor function cavenue() { $this->code = 'cavenue'; $this->title = MODULE_PAYMENT_CCAVENUE_TEXT_TITLE; $this->description = MODULE_PAYMENT_CCAVENUE_TEXT_DESCRIPTION; $this->enabled = MODULE_PAYMENT_CCAVENUE_STATUS; $this->form_action_url = 'https://www.ccavenue.com/shopzone/cc_details.jsp'; } // class methods function javascript_validation() { return false; } function selection() { return array('id' => $this->code, 'module' => $this->title); } function pre_confirmation_check() { return false; } function confirmation() { return false; } function process_button() { global $order, $currencies,$customer_id, $MerchantId, $Amount, $OrderId, $Url, $WorkingKey, $Checksum ; $MerchantId = MODULE_PAYMENT_CCAVENUE_MERCHANT_ID; $Amount = $order->info['total']; $OrderId = $customer_id . '-' . date('Ymdhis'); $Url = tep_href_link(FILENAME_CHECKOUT_PROCESS,'','SSL',false); $pattern='http://www\.'; if(!(Eregi($pattern,$Url,$reg))) eregi_replace('http://', $pattern, $Url); $WorkingKey = MODULE_PAYMENT_CCAVENUE_WORKING_KEY; $str ="$MerchantId|$OrderId|$Amount|$Url|$WorkingKey"; $adler = 1; $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>"; } $str = $s2; $num = 16; $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>"; } $num=$str; for ($n = 0 ; $n < strlen($num) ; $n++) { $temp = $num[$n] ; $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1); } $Checksum = $dec + $s1; $AuthDesc = 'N'; $process_button_string = tep_draw_hidden_field('Merchant_Id', $MerchantId) . tep_draw_hidden_field('Order_Id', $OrderId) . tep_draw_hidden_field('Amount', number_format($order->info['total'] * $currencies->currencies['INR']['value'], $currencies->currencies['INR']['decimal_places'], '.', '')) . tep_draw_hidden_field('billing_cust_name', $order->customer['firstname'].' '. $order->customer['lastname']) . tep_draw_hidden_field('billing_cust_address', $order->billing['street_address']) . tep_draw_hidden_field('billing_cust_country', $order->billing['country']['iso_code_2']) . tep_draw_hidden_field('billing_cust_email', $order->customer['email_address']) . tep_draw_hidden_field('Checksum',$Checksum) . tep_draw_hidden_field('delivery_cust_name', $order->delivery['firstname'].' '.$order->delivery['lastname']) . tep_draw_hidden_field('delivery_cust_address', $order->delivery['street_address']) . tep_draw_hidden_field('delivery_cust_country', $order->delivery['country']['iso_code_2']) . tep_draw_hidden_field('Redirect_Url',$Url); return $process_button_string; } function before_process() { global $HTTP_POST_VARS, $customer_id, $MerchantId, $Amount, $OrderId, $WorkingKey, $Checksum,$AuthDesc,$sum ; $MerchantId = $HTTP_POST_VARS['Merchant_Id']; $Amount = $HTTP_POST_VARS['Amount']; $OrderId = $HTTP_POST_VARS['Order_Id']; $Checksum = $HTTP_POST_VARS['Checksum']; $AuthDesc = $HTTP_POST_VARS['AuthDesc']; $WorkingKey = MODULE_PAYMENT_CCAVENUE_WORKING_KEY; $str ="$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey"; $adler = 1; $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>"; } $str = $s2; $num = 16; $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>"; } $num=$str; for ($n = 0 ; $n < strlen($num) ; $n++) { $temp = $num[$n] ; $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1); } $sum = $dec + $s1; if($sum == $Checksum) $Checksum = 'true' ; else $Checksum = 'false'; if($Checksum != 'true'){ tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_CCAVENUE_ALERT_ERROR_MESSAGE), 'SSL', true, false)); } if($Checksum =='true' && $AuthDesc == 'N'){ tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_CCAVENUE_TEXT_ERROR_MESSAGE), 'SSL', true, false)); } } function after_process() { return false; } function output_error() { global $HTTP_GET_VARS; $output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" . ' <tr>' . "\n" . ' <td class="main"> <font color="#FF0000"><b>' . MODULE_PAYMENT_CCAVENUE_TEXT_ERROR . '</b></font><br> ' . MODULE_PAYMENT_CCAVENUE_TEXT_ERROR_MESSAGE . ' </td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n"; return $output_error_string; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_CCAVENUE_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable CCAVENUE Module', 'MODULE_PAYMENT_CCAVENUE_STATUS', '1', 'Do you want to accept CCAVENUE payments?', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant Id', 'MODULE_PAYMENT_CCAVENUE_MERCHANT_ID', 'CCAvenueMerchantID', 'The Merchant Id to use for the CCAVENUE service', '6', '1', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('WorkingKey', 'MODULE_PAYMENT_CCAVENUE_WORKING_KEY', '', 'put in the 32 bit alphanumeric key.Please note that get this key ,login to your CCAvenue merchant account and visit the \"Generate Working Key\" section at the \"Settings & Options\" page.', '6', '2', now())"); } function remove() { $keys = ''; $keys_array = $this->keys(); for ($i=0; $i<sizeof($keys_array); $i++) { $keys .= "'" . $keys_array[$i] . "',"; } $keys = substr($keys, 0, -1); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")"); } function keys() { return array('MODULE_PAYMENT_CCAVENUE_STATUS', 'MODULE_PAYMENT_CCAVENUE_MERCHANT_ID','MODULE_PAYMENT_CCAVENUE_WORKING_KEY'); } } ?> Link to comment Share on other sites More sharing options...
yogidegr8 Posted February 5, 2004 Author Share Posted February 5, 2004 I come to know that it just need to run the checkout_proccess.php to complete the order, update database and send mails. Isn't there any way I can do this.. Link to comment Share on other sites More sharing options...
yogidegr8 Posted February 6, 2004 Author Share Posted February 6, 2004 I am now getting the payment but the database is not updating so not being able to know what the customers are ordering???? Please suggest what changes to do. I have tried my best to solve it but am not being able to reach that leval... Help is appriciated. Link to comment Share on other sites More sharing options...
Pharkie Posted February 6, 2004 Share Posted February 6, 2004 Sounds like you have a problem similar to that with the Worldpay integration for OSC. You need to ensure that the customer goes right through the process, i.e. gets to checkout_process.php. This is after the transaction is completed, and the bit that puts the order into the database. With Worldpay this is done via a HTTP-REFRESH redirect on the page that's returned from Worldpay, maybe that's what you need? Or if you're using a contribution, email the author.. Link to comment Share on other sites More sharing options...
yogidegr8 Posted February 7, 2004 Author Share Posted February 7, 2004 Yes, this is the same problem. I am using a contribution: http://www.oscommerce.com/community/contributions,838/page,2 I had a talk on phone with the author, she is asking for money now.... I am a bit stuckup now.. Link to comment Share on other sites More sharing options...
Pharkie Posted February 8, 2004 Share Posted February 8, 2004 Asking for money to fix an Open Source contribution to an Open Source product that isn't working in a major way is unfair IMHO, bad karma! You may want to look into using another payment provider, one that has a plugin for OSC that definitely works.. The Worldpay one works well enough, and the Paypal ones for smaller sites are good too. The change you need to get CCAvenue working probably isn't that difficult. Try just adding this tag in the <HEAD> section of the page before checkout_process.php: <meta http-equiv="refresh" content="3;url=checkout_process.php"> See if you can get that working yourself, or find someone nice who's also using CCAvenue and has more experience with OSC than you. Good luck, hope you get it sorted! Link to comment Share on other sites More sharing options...
yogidegr8 Posted February 9, 2004 Author Share Posted February 9, 2004 Thanks for your help. I am not having the control over the payment gateway last page so that it redirects to checkout_proccess.php Is there any way that we add something to the order confirmation page so it initiate the checkout_proccess.php before sending the information to the payment gateway at ccavenue, and proceed to the secure server. Link to comment Share on other sites More sharing options...
vinay85 Posted May 29, 2006 Share Posted May 29, 2006 I have updated the contribution for CC avenue to include the latest setting from the gateway. You can find it at ( http://www.oscommerce.com/community/contributions,838/page,5 ) To make it work you also need to update some settings in your CC avenue control panel. In your control panel there is a setting for return URL after the transaction is complete. Please add http://yourdomain.com/catalog/checkout_proccess.php to that field. Once the transaction process is complete it will point it back to your website and update your order. It is quite sad that the original contributer is asking for money in an open source project. Link to comment Share on other sites More sharing options...
mnkumar Posted October 8, 2006 Share Posted October 8, 2006 I have updated the contribution for CC avenue to include the latest setting from the gateway. You can find it at ( http://www.oscommerce.com/community/contributions,838/page,5 )To make it work you also need to update some settings in your CC avenue control panel. In your control panel there is a setting for return URL after the transaction is complete. Please add http://yourdomain.com/catalog/checkout_proccess.php to that field. Once the transaction process is complete it will point it back to your website and update your order. It is quite sad that the original contributer is asking for money in an open source project. Hi Vinay, I am using the mod developed by you an Kavita Agarwal. Is there any place other than the Admin module where you need to enter the merchant ID. I am getting an Invalid Merchant ID eror after clicking the confirm order button. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.