PayPal 网关已拒绝请求。购物车项目总金额与订单金额不匹配。 Magento

Posted

技术标签:

【中文标题】PayPal 网关已拒绝请求。购物车项目总金额与订单金额不匹配。 Magento【英文标题】:PayPal gateway has rejected request. the totals of the cart item amounts do not match order amounts. Magento 【发布时间】:2014-11-27 10:42:27 【问题描述】:

我很清楚发生了什么。我不知道如何解决它。由于我要求贝宝包含订单项,它会计算订单项总数,但它们与总计不匹配。

config.xml

    <sales>
        <quote>
            <totals>
                <biddiscount>
                    <class>winints/biddiscount</class>
                    <before>subtotal</before>
                </biddiscount>
                <globaldiscount>
                    <class>winints/globaldiscount</class>
                    <before>subtotal</before>
                </globaldiscount>
            </totals>
        </quote>
    </sales>

GlobalDiscount 类

<?php
/**
 * Created by PhpStorm.
 * User: numerical25
 * Date: 5/17/14
 * Time: 7:49 PM
 */

class Superior_WinInts_Model_Globaldiscount extends Mage_Sales_Model_Quote_Address_Total_Subtotal 

    protected  $amount = 0;
    protected  $set = 0;

    public function collect(Mage_Sales_Model_Quote_Address $address) 
        if ($address->getData('address_type') == 'billing')
            return $this;
        $discount = Mage::app()->getRequest()->getParam('global_discount_amount');
        $grandTotal = $address->getGrandTotal();
        $baseGrandTotal = $address->getBaseGrandTotal();
        if(Mage::getSingleton('customer/session')->isLoggedIn() && $discount) 

            $customer =  Mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getId());
            $credit =  Mage::getModel("winints/wallet")
                ->getCustomerStoreCreditTotal($customer->getId());
            if($credit >= $discount) 
                $this->amount = $discount;
            
            Mage::getSingleton('core/session')->setGlobalDiscount($discount);

            $totals = array_sum($address->getAllTotalAmounts());
            $baseTotals = array_sum($address->getAllBaseTotalAmounts());
            //You have to set Grand and Base Grand Total for this crap to work
            $address->setDiscountAmount(-$discount);
            $address->setBaseDiscountAmount(-$discount);
            $address->setGrandTotal($grandTotal - $discount);
            $address->setBaseGrandTotal($baseGrandTotal - $discount);
            $address->setSubtotal($baseGrandTotal - $discount);

         else if (Mage::getSingleton('core/session')->getGlobalDiscount()) 
            $discount = Mage::getSingleton('core/session')->getGlobalDiscount();
            $this->amount = Mage::getSingleton('core/session')->getGlobalDiscount();
            $address->setDiscountAmount(-$discount);
            $address->setBaseDiscountAmount(-$discount);
            $address->setGrandTotal($grandTotal - $discount);
            $address->setBaseGrandTotal($baseGrandTotal - $discount);
            $address->setSubtotal($baseGrandTotal - $discount);
        
        return $this;
    

    public function fetch(Mage_Sales_Model_Quote_Address $address)
    
        if(Mage::getSingleton('core/session')->getGlobalDiscount()) 
            if(!$this->set) 
                $address->addTotal(array(
                    'code'=>$this->getCode(),
                    'title'=>Mage::helper('catalog')->__('Global Discount (-)'),
                    'value'=> $this->amount
                ));
                $this->set = 1;
            
        
        return $this;
    

我已经完成了教程告诉我的所有事情,我尝试更新基本总计、总计、小计等所有内容。它仍然没有正确匹配

我做错了什么??

还有其他帖子,但不清楚。显然,行项目从总计中计算不正确。 .

【问题讨论】:

【参考方案1】:

想通了,是的,网上的参考资料不正确。

在你的配置 xml 中

            <globaldiscount>
                <class>winints/globaldiscount</class>
                <before>subtotal</before>
            </globaldiscount>

将标签中的之前更改为和值应为“grand_total”

<after>grand_total</after>

如果您将其放在小计之前或之后,您的折扣将不会考虑总计,因为总计是最后计算的。

因此您的代码可能会计算小计,但不会计算总计,这可能会给贝宝提供不准确的估计

【讨论】:

以上是关于PayPal 网关已拒绝请求。购物车项目总金额与订单金额不匹配。 Magento的主要内容,如果未能解决你的问题,请参考以下文章

PayPal 错误 10413 - 购物车项目总金额与订单金额不匹配

Paypal 不返回实际总金额

PayPal API:购物车项目总金额与订单金额不匹配

10413 贝宝错误:购物车项目总金额与订单金额不匹配

“PayPal 网关已拒绝请求。超时处理请求(#10001:内部错误”

paypal magento 不支持 INR