2

Had received a module from CCAVENUE and it was working fine with Magento 1.6.2... but just recently it has started giving an error of undefined variable dec..

Has anybody had a similar issue? And any work arounds tried... any help and suggestion would be greatly appreciated.

Error

Notice: Undefined variable: dec in /home/maationl/public_html/app/code/core/Mage/Avenues/controllers/libfuncs.php3

And the relevant code

<?php 
function cdec($num) { 
    for ($n = 0 ; $n < strlen($num) ; $n++) { 
        $temp = $num[$n] ; 
        $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
    } 
    return $dec;
} 
?>
sg3s
  • 9,411
  • 3
  • 36
  • 52
Moody
  • 235
  • 1
  • 7
  • 21
  • This is not the place to seek vendor specific help, please contact ccavenue for help in this case. Alternatively if you find that you're unable to solve the problem when debugging, please provide us with context and material to be able to help you (code, errors that occur, and expected behaviour). – sg3s Jun 24 '12 at 12:34
  • sorry... it was a free magento module... – Moody Jun 24 '12 at 12:47
  • this is the error im getting... Notice: Undefined variable: dec in /home/maationl/public_html/app/code/core/Mage/Avenues/controllers/libfuncs.php3 on line 62 – Moody Jun 24 '12 at 12:48
  • and the code is – Moody Jun 24 '12 at 12:51
  • sorry wasnt sure how to add code in proper format... kindly excuse. – Moody Jun 24 '12 at 12:52
  • Even if you don't know how to properly format it, just dump it in there somewhat readable, there will be people that can edit it to look nice and they will. There are 3 good ways of adding code, prepending them with spaces/tabs, backticks for inline code, or the `` html tag. http://stackoverflow.com/editing-help – sg3s Jun 24 '12 at 13:05
  • This seems like a blatant bug in the plugin you have, I would still advice contacting ccavenue to report the bug. Their plugin was probably written by them or by a company they hired to make a Magento implementation and they should fix the bugs. – sg3s Jun 24 '12 at 13:23
  • You get what you pay for & you pay for what you get. This "free" Magento module is established inside of the Magento core code pool indicating a poor understanding of the module author (if it was installed as delivered). – benmarks Jun 24 '12 at 13:24
  • @benmarks I would agree with that weren't it for a fact that payment providers have a lot to gain by properly supporting e-commerce solutions since they usually get payed per transaction etc. They should be ashamed offering products with bugs like these, for me this means CCAvenue will never be a payment provider for anything, and my advice as a software engineer does mean something to my customers. – sg3s Jun 24 '12 at 13:33
  • ...oops. My comment should be "poor understanding *by* the module author" indicating that this module should not be used. That said, it very well may be the case that CCAvenue have not authored the extension themselves and may not be at fault for the poor code. Their failure to provide a module of their own (if that is the case) though indicates that they are not a proper option for Magento. – benmarks Jun 24 '12 at 15:00
  • Hi moody.. Can you sent me the payment integration module which you received from ccavenue. I tried to contact ccavenue guys but cant get them. – itdeeps Nov 25 '12 at 07:13

1 Answers1

2

The precise error you mention can be fixed by defining $dec before using it.

<?php 
function cdec($num) { 
    $dec = 0;
    for ($n = 0 ; $n < strlen($num) ; $n++) { 
        $temp = $num[$n] ; 
        $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
    } 
    return $dec;
} 
?>

What I suspect happened is that you enabled error reporting and you're now getting errors from the plugin which have been in there forever.

It usually isn't advisable to edit code which is in the core of Magento or plugins you didn't create yourself (for upgradability) but looking at that path it might not actually be a proper Magento module.

I've had the pleasures of adding payment providers to Magento with plugins provided by the payment gateway which were riddled with bugs, not tested quite well enough, or not even written by the Magento guidelines...

You're probably better of editing this one file, document it, and remember to keep that documentation on hand once you do an upgrade.

sg3s
  • 9,411
  • 3
  • 36
  • 52
  • 1
    Good advice. It's worth noting that this file can be duplicated under the local or community codePool, edited in place, and note for future upgrade. – benmarks Jun 24 '12 at 13:27
  • This is actually what happened.. i got this module from ccavenue india for connecting my Magento website with CCAVENUE payment gateway. For debugging purposes i activated error reporting and suddenly all hell broke loose. This NOTICE error comes in while the website is being redirected to CCAVENUE. Unable to work on the module, i tried hiding error reporting NOTICES. This solved the immediate problem as the Notice was invisible and the site REDIRECTED as required....
    – Moody Jul 04 '12 at 10:09
  • Further, after accepting payment it is also giving a WARNING now. So i could hide WARNINGS also. But im sure this is not the right way to deal with it... And CCAVENUE people are the least interested in helping with this issue :-( – Moody Jul 04 '12 at 10:13
  • thanks sg3s and benmarks for ur observations... but what is the way forward... sorry im kinda new to Magento.. and creating or editing Modules is a little scary... – Moody Jul 04 '12 at 10:15
  • @Moody I would strongly suggest to find a payment provider which provide a Magento plugin which doesn't throw errors all over the place when you simply enable debugging. If you want to continue with CCAVENUE I would suggest you to get ready to rewrite/spend a lot of time into it debugging the plugin entirely... Even better, implement a plugin that uses their API and sell it to them... But tbh, you should just ditch them as a payment provider. Providers like PayPal and the default included Moneybookers plugin are probably better options. – sg3s Jul 05 '12 at 16:16
  • @sg3s The problem of dec was solved using your solution. Thanxs. As far as the warning is concerned... had a long discussion with the CCAVENUE tech team... and it appears it was a permission issue.. Havent got a chance to completely vhet it... but its working fine.. with warnings hidden... and presently cant thinh of changing payment gateways.... thanxs all.. – Moody Jul 23 '12 at 17:17
  • @Moody in that case don't hesitate to accept it as the right answer ^^ – sg3s Jul 23 '12 at 17:49