【问题标题】:Magento: Retrieve payment information with Authorize.net gatewayMagento:使用 Authorize.net 网关检索付款信息
【发布时间】:2012-11-02 17:43:03
【问题描述】:

我在基于 magento 的购物车中使用 Authorize.net 支付网关。它是仅授权,这意味着我首先对卡进行授权,然后在将产品运送给客户后,我会获取金额。

Authorize paygate 以序列化形式将 cc_exp_month、cc_exp_year 等信息存储在表 sales_flat_order_payment 的“additional_information”字段中。

magento 中是否有任何方法可以简单地从附加信息列中检索这些值(cc_exp_month、cc_exp_year)?

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    magento 中是否有任何方法可以从附加信息列中简单地检索这些值(cc_exp_month,cc_exp_year)?

    不,没有。您需要深入了解 additional_information 数组。这是我添加的用于检索 cc_type 值的方法。它可以很容易地调整为返回所有数据或只是另一部分:

    public function getCcType(Mage_Sales_Model_Order_Payment $payment)
    {
        if(count($payment->getAdditionalInformation()))
        {
            foreach($payment->getAdditionalInformation() as $auth_cards)
            {
                foreach($auth_cards as $ac_id)
                {
                    if(isset($ac_id['cc_type']))
                    {
                        return $ac_id['cc_type'];
                    }
                }
            }
        }
        return false;
    }
    

    【讨论】:

      【解决方案2】:

      试试

      $order_id = 113
      $order = Mage::getModel('sales/order')->load($order_id);
      

      如果信息存储 cc_exp_month 和 cc_exp_year

      $ccExpMonth = $order->getPayment()->getCcExpMonth();
      $ccExpYear = $order->getPayment()->getCcExpYear();
      

      如果信息存储在附加信息中

      $ccExpMonth = $order->getPayment()->getAdditionalInformation('cc_exp_month');
      $ccExpYear = $order->getPayment()->getAdditionalInformation('cc_exp_year');
      

      【讨论】:

      • R.S - 这样它不会获取值,有关详细信息,请参阅我在 ceckoslab 的答案中添加的评论。
      • 看看我更新的答案..你在 cc_exp_month 和 cc_exp_year (同一张表)中有任何信息吗?这是我的 cim 模块存储它的地方
      • “authorize_cards”在数据库的哪一列?做 print_r($order->getPayment()->getAdditionalInformation()-getData()) 看看你得到什么结果
      【解决方案3】:

      我相信接下来的 2 行就可以解决问题:

      $ccExpMonth = $order->getPayment()->getAdditionalInformation('cc_exp_month');
      $ccExpYear = $order->getPayment()->getAdditionalInformation('cc_exp_year');
      

      当然 $order 是 Mage_Sales_Model_Order 的实例。

      您也可以参考:how to get payment information on Magento?

      【讨论】:

      • 我之前看过那篇文章并尝试了与您建议的相同的方法,但它没有获取这样的值。我检查并发现 authorize.net 将这些信息存储在一个数组“authorize_cards”中,所以如果我们尝试直接获取它们,它们就不会出现。为此,我应用了一个 foreach 循环然后获取值,但不确定这是否合乎逻辑且正确?
      猜你喜欢
      • 2012-11-29
      • 2011-06-23
      • 2014-11-30
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 2013-07-31
      • 2018-08-12
      • 2016-06-26
      相关资源
      最近更新 更多