Magento - Paypal Express - Checkout sending incorrect postcode

1.3k Views Asked by At

We are running Magento ver. 1.9.0.1 and only recently we've encountered an issue with Paypal. we are using Paypal Express Checkout.

If the customer enters a shipping address and a different billing address, the checkout is sending the billing post code with the rest of the shipping address.

Eg:

Billing Address

123 John Lane London SW1 3AA

Shipping Address

333 Peter Lane London SW14 4AA

The address that shows when the customer is redirected to Paypal is.. 333 Peter Lane, London, SW1 3AA.

Has anyone encountered this issue and can help?

1

There are 1 best solutions below

0
On BEST ANSWER

ran to the same problem myself recently. The good news is - I found a solution.

Paypal Express Checkout behaves that way when the shipping and billing addresses are different, but the "same_as_billing" attribute of the shipping address in the quote is set to 1. There are probably many ways you can end up in that situation.

In my case, it was a checkout extension I used (onestepcheckout by idev), which neglected to set same_as_billing attribute of the shipping address in the quote during checkout, when the shipping address was different from the billing address.

You can check if the same_as_billing attribute is set correctly during checkout with the following code (to get the output of the var_dump, you can put the code into a controller of your choice and making):

$quote = Mage::getSingleton('checkout/session')->getQuote();
var_dump($quote->getShippingAddress()->getData()); 

In my case of the onestepcheckout extension, the fix was to change the code in app/code/local/Idev/OneStepCheckout/controllers/AjaxController.php from:

    if(!empty($billing_data['use_for_shipping'])) {
       $shipping_data = $billing_data;
    }

to:

    if(!empty($billing_data['use_for_shipping'])) {
       $shipping_data = $billing_data;
       $shipping_data['same_as_billing'] = 1;
    } else {
       $shipping_data['same_as_billing'] = 0;
    }

Hope this reply saves some debugging time to other who stumble upon the same bug.