Magento 1.4 Paypal 错误

标签 magento paypal

我尝试在我的 magento 1.4 中运行 paypal 支付,但工作流程存在严重问题。在我选择 paypal 并路由到 paypal 帐户发送钱后,您通常会自动返回到 magento 商店以完成订单,但在我的情况下,magento 告诉您地址字段存在问题。 paypal 不会将地址正确发送回 magento:

Error: Please check shipping address information. Please enter last name.

这是已知错误还是有补丁或解决方法?

请帮忙! 谢谢。

最佳答案

错误似乎在/app/code/core/Mage/Paypal/Model/Api/Nvp.php。看起来变量没有很好地映射。因为我找不到这个文件中的具体错误,所以我在 /app/code/core/Mage/Paypal/Model/Express/Checkout.php 中做了一些肮脏的解决方法。

1.4.2 中,只需将方法 returnFromPaypal() 替换为以下代码...

public function returnFromPaypal($token)
{
    $this->_getApi();
    $this->_api->setToken($token)
        ->callGetExpressCheckoutDetails();

    // import billing address
    $billingAddress = $this->_quote->getBillingAddress();
    $exportedBillingAddress = $this->_api->getExportedBillingAddress();

    // import shipping address
    $exportedShippingAddress = $this->_api->getExportedShippingAddress();
    if (!$this->_quote->getIsVirtual()) {
        $shippingAddress = $this->_quote->getShippingAddress();
        if ($shippingAddress) {
            if ($exportedShippingAddress) {
                foreach ($exportedShippingAddress->getExportedKeys() as $key) {
                    if('firstname' == $key || 'lastname' == $key){
                        continue;
                    } // if
                    $shippingAddress->setDataUsingMethod($key, $exportedShippingAddress->getData($key));
                    $billingAddress->setDataUsingMethod($key, $exportedShippingAddress->getData($key));
                }

                // Correct First- and Lastnames
                list($_firstname, $_lastname) = explode(' ', $exportedShippingAddress->getData('firstname'));

                $shippingAddress->setDataUsingMethod('firstname', $_firstname);
                $billingAddress->setDataUsingMethod('firstname', $_firstname);

                $shippingAddress->setDataUsingMethod('lastname', $_lastname);
                $billingAddress->setDataUsingMethod('lastname', $_lastname);

                $shippingAddress->setCollectShippingRates(true);
            }

            // import shipping method
            $code = '';
            if ($this->_api->getShippingRateCode()) {
                if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
                     // possible bug of double collecting rates :-/
                    $shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
                }
            }
            $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD, $code);
        }
    }
    $this->_ignoreAddressValidation();

    // import payment info
    $payment = $this->_quote->getPayment();
    $payment->setMethod($this->_methodType);
    Mage::getSingleton('paypal/info')->importToPayment($this->_api, $payment);
    $payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())
        ->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
    ;
    $this->_quote->collectTotals()->save();
}

修改后的代码将整个账单地址替换为送货地址,并将 $firstname 中给出的姓名推送到 $firstname 和 $lastname。

不干净,但工作。 :-)

关于Magento 1.4 Paypal 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3306769/

相关文章:

templates - Magento 代码 $this->getChildHtml ('topContainer' );

php - Magento 自定义支付方式

javascript - Paypal 不会将沙盒交易数据发送到 IPN

php - Paypal 大众支付 : Insufficient funds response

mysql - 组连接限制 1

magento - 覆盖\app\code\core\Mage\Core\Block\Messages.php

magento - Magento 模块验证器是否存在?

ssl - PayPal 网站支付专业版 TLS

paypal - 未通过 Paypal Express Checkout API 收款

php - Paypal : Transfer money using API credentials