How to debug magento payment gateways
I am just a little curious. What can I do to make my debugging experience with payment gateways a little easier. On check out, it always does the ajax calls. So there is no way I can print_r() or echo to see the progression. Is there a easier 开发者_高级运维way to do it without destroying nothing. Is it possible to disable the ajax calls and make a regular post.
Short answer is: Do this for non-destructive debugging.
Mage::log("Logging a message");
Long answer follows.
I haven't done a ton of payement gateway debugging, but many of the payment gateways have a "debug" setting in
System -> Configuration -> Sales -> Payment Methods
Check the authorize.net option group for an example of this. If you flip this to the "yes" position debug information will start spewing to the log file. This assumes you've turned logging on in
System -> Configuration -> Advanced -> Developer -> Log Settings
You may need to create the log files yourself in
var/log/system.log
var/log/exception.log
Make sure these files are writable by your web server.
You can also log to these files yourself with the static
Mage::log("Logging a message");
method call.
Finally, if your payment gateway doesn't have a debug setting, you could always fake it. All Payment Model (are supposed to) inherit from the following class
class Mage_Payment_Model_Method_Abstract
app/code/core/Mage/Payment/Model/Method/Abstract.php
This class has a method that determines if debugging is on or off
/**
* Define if debugging is enabled
*
* @return bool
*/
public function getDebugFlag()
{
return $this->getConfigData('debug');
}
If there's no debug config flag available, you could temporarily change this method to always return true
public function getDebugFlag()
{
return 1;
//return $this->getConfigData('debug');
}
However, I'm not sure how much debugging the base classes do (meaning if there's no debug flag in the config, that may be because there's no debugging going on in the payment gateway model itself). Worth exploring though.
Good luck!
For AJAX you might find FirePHP for Magento helpful.
For all situations you can use Mage::log()
as long as you remember to turn it on first in System > Configuration > Developer. It works a lot like print_r
except it outputs to /var/log/system.log
.
I often tailf
that file and have code like this in lots of places:
Mage::log(__METHOD__); // prints My_Module_Model_Class::method
Mage::log($object->debug()); // $object is any model or block descending from Varien_Object
精彩评论