Magento 1.4 paypal bug
i try to get the paypal payment run in my magento 1.4 but there is a serious problem with the workflow. after i select paypal and get routed to the paypal account to send the money you normally come back automatically into the magento开发者_如何学JAVA shop to finish the order, but in my case magento tells you there is aproblem with the adress field. paypal does'nt send the adress back to magento correctly:
Error: Please check shipping address information. Please enter last name.
is this a known bug or is there a patch or workaround?
please help! thnx.
The error seems to be in /app/code/core/Mage/Paypal/Model/Api/Nvp.php. Looks like the vars aren't mapped well. Because I couldn't find the concrete error in this file, I did a bit dirty workaround in /app/code/core/Mage/Paypal/Model/Express/Checkout.php.
In 1.4.2 just replace the method returnFromPaypal() with the following code...
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();
}
The modified code replaces the whole billing address with the shipping address and pushes the name given in $firstname into $firstname and $lastname.
not clean, but working. :-)
any luck finding a solution to this, I'm having the same issue.
--- update ---
I finally figured out what was happening on this one for me. I had the Custom Shipping Admin module installed and it was overriding the address controller that validates the order. I updated the overrided module to reflect the version of Magento I was on and it worked.. no problems. Hope this helps someone.
精彩评论