1. Magento: Using custom address fields with PayPal and SagePay

    There are quite a few gotcha’s and difficulties whenever you start modifying or customizing the address fields on the one-page-checkout of a Magento install (especially when you have a theme installed).

    For a project, we wanted to be able to define custom items from the Country Select Dropdown, in particularly BFPO address options that don’t match up to any specific country codes in Magento or any Payment gateways.

    PayPal - Using the standard Magento PayPal module

    Challenge 1: Convincing PayPal not to try and validate or expect an address from the Magento Store.

    To do this you have to firstly set ”address_override=1” to force PayPal to use it’s own address:

    app/code/core/Mage/Paypal/Model/Api/Npv.php  (line 362)

    $request[‘ADDROVERRIDE’] = 0;

    app/code/core/Mage/Paypal/Model/api/Standard.php (line 199)

    $request[‘address_override’] = 0;


    Challenge 2: Instructing PayPal not try and collect or display an address on the PayPal page.

    app/code/core/Mage/Paypal/Model/Api/Npv.php on Line 554 - added

    $request[‘NOSHIPPING’] = 1;

    This prevented the address showing up on the Paypal payment page - also used the original delivery address captured in magento in the final order confirmation screen.

    SagePay - using the Ebizmarts SagePay Suite Module

    (http://ebizmarts.com/sage-pay-suite)

    SagePay is a little easier to workaround as all we have to do is change the value of a variable to get the billing address instead of the shipping address (billing address always has to be a valid card address - no custom fields).

    To change getBillingAddress instead of getShippingAddress

    app/code/local/Ebizmarts/SagePaySuite/Model/SagePayForm.php - (Line 97)

    from

    $shipping = $quoteObj->getShippingAddress();

    to 

    $shipping = $quoteObj->getBillingAddress();