如何调试magento支付网关

发布于 2024-10-06 17:52:13 字数 135 浏览 1 评论 0原文

我只是有点好奇。我可以做些什么来让我的支付网关调试体验变得更容易一些。签出时,它总是执行 ajax 调用。所以我无法通过 print_r() 或 echo 来查看进度。有没有更简单的方法来做到这一点而不破坏任何东西。是否可以禁用 ajax 调用并定期发帖。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

锦爱 2024-10-13 17:52:13

简短的回答是:这样做是为了进行非破坏性调试。

Mage::log("Logging a message");

长答案如下。

我没有进行大量的支付网关调试,但许多支付网关在

System -> Configuration -> Sales -> Payment Methods

检查authorize.net 选项组中都有“调试”设置以获取相关示例。如果将其翻转到“是”位置,调试信息将开始涌入日志文件。这假设您已打开登录功能,

System -> Configuration -> Advanced -> Developer -> Log Settings

您可能需要在

var/log/system.log
var/log/exception.log

确保这些文件可由您的 Web 服务器写入中自行创建日志文件。

您还可以使用静态方法调用自行记录这些文件

Mage::log("Logging a message");

最后,如果您的支付网关没有调试设置,您总是可以伪造它。所有支付模型(应该)继承自以下类

class Mage_Payment_Model_Method_Abstract
app/code/core/Mage/Payment/Model/Method/Abstract.php

该类有一个方法可以确定调试是打开还是关闭

/**
 * Define if debugging is enabled
 *
 * @return bool
 */
public function getDebugFlag()
{
    return $this->getConfigData('debug');
}

如果没有可用的调试配置标志,您可以暂时更改此方法以始终返回 true

public function getDebugFlag()
{
    return 1;
    //return $this->getConfigData('debug');
}

但是,我不是确定基类做了多少调试(意味着如果配置中没有调试标志,那可能是因为支付网关模型本身没有进行调试)。不过值得探索。

祝你好运!

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!

难忘№最初的完美 2024-10-13 17:52:13

对于 AJAX,您可能会发现 FirePHP for Magento 很有帮助。

对于所有情况,您都可以使用 Mage::log(),只要您记得首先在系统 > 中将其打开即可。配置>开发人员。它的工作方式很像 print_r,只不过它输出到 /var/log/system.log

我经常 tailf 该文件,并且在很多地方都有这样的代码:

Mage::log(__METHOD__); // prints My_Module_Model_Class::method
Mage::log($object->debug()); // $object is any model or block descending from Varien_Object

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文