编程语言
首页 > 编程语言> > php-即使PayPal付款失败,Magento订单状态也会更新为“处理中”

php-即使PayPal付款失败,Magento订单状态也会更新为“处理中”

作者:互联网

Magento 1.9和PayPal付款方式存在问题.
当客户使用PayPal付款并且有付款审核时,在这种情况下,订单状态将设置为正确的“付款审核”.

但是,问题是,在付款实际失败的情况下(即客户帐户中的资金不足),Magento将订单状态更新为“处理中”和“客户最终获得免费商品.

我需要做的是,当调用“失败” IPN时,我需要将“关闭”状态设置为该特定顺序.我花了4个多小时来找到解决方案,但没有找到合适的解决方案.

如果有人对此有任何修复,请与我分享.

PayPal IPN响应变量:

        [payer_email] => xxx@xxx.com
        [payer_id] => xxxxxxxxxxxx
        [payer_status] => unverified
        [payment_date] => 14:33:46 Jun 08, 2015 PDT
        [payment_gross] => 43.24
        [payment_status] => Failed
        [payment_type] => echeck
        [protection_eligibility] => Ineligible

提前致谢.

解决方法:

我们面临同样的问题,并找到了根本原因.在Magento Bug Tracker上,这似乎是一个未解决的问题.

查看https://www.magentocommerce.com/bug-tracking/issue/index/id/1041

您可以通过重写Ipn模型来修复它,如下所示:

<?php
/**
 * Rewrite the core fix an issue with IPN notifications of "failed" payments
 */
class Magento_CoreFixes_Model_Paypal_Ipn extends Mage_Paypal_Model_Ipn
{

    /**
     * @see https://www.magentocommerce.com/bug-tracking/issue/index/id/1041
     */
    protected function _registerPaymentFailure()
    {
        $this->_importPaymentInformation();

        // This is the fix allowing order to get the cancelled status
        foreach ($this->_order->getInvoiceCollection() as $invoice){
            $invoice->cancel()->save();
        }

        $this->_order
            ->registerCancellation($this->_createIpnComment(''), false)
            ->save();
    }
}

希望能帮助到你!

标签:magento-1-9,payment-gateway,php,paypal,paypal-ipn
来源: https://codeday.me/bug/20191028/1950521.html