Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 468

Get Full Billing Address for Paypal Express [Magento]

$
0
0

The paypal module tries to map the billing information that is returned (usually nothing) from Paypal over the billing information entered by the user during the checkout process. I've fond the code that does this in NVP.php model.

/**     * Create billing and shipping addresses basing on response data     * @param array $data     */    protected function _exportAddressses($data)    {        $address = new Varien_Object();        Varien_Object_Mapper::accumulateByMap($data, $address, $this->_billingAddressMap);        $address->setExportedKeys(array_values($this->_billingAddressMap));        $this->_applyStreetAndRegionWorkarounds($address);        $this->setExportedBillingAddress($address);        // assume there is shipping address if there is at least one field specific to shipping        if (isset($data['SHIPTONAME'])) {            $shippingAddress = clone $address;            Varien_Object_Mapper::accumulateByMap($data, $shippingAddress, $this->_shippingAddressMap);            $this->_applyStreetAndRegionWorkarounds($shippingAddress);            // PayPal doesn't provide detailed shipping name fields, so the name will be overwritten            $shippingAddress->addData(array('prefix'     => null,'firstname'  => $data['SHIPTONAME'],'middlename' => null,'lastname'   => null,'suffix'     => null,            ));            $this->setExportedShippingAddress($shippingAddress);        }    }    /**     * Adopt specified address object to be compatible with Magento     *     * @param Varien_Object $address     */    protected function _applyStreetAndRegionWorkarounds(Varien_Object $address)    {        // merge street addresses into 1        if ($address->hasStreet2()) {             $address->setStreet(implode("\n", array($address->getStreet(), $address->getStreet2())));             $address->unsStreet2();        }        // attempt to fetch region_id from directory        if ($address->getCountryId() && $address->getRegion()) {            $regions = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getRegionCollection()                ->addRegionCodeFilter($address->getRegion())                ->setPageSize(1)            ;            foreach ($regions as $region) {                $address->setRegionId($region->getId());                $address->setExportedKeys(array_merge($address->getExportedKeys(), array('region_id')));                break;            }        }    }

Has anyone had any success modifying this process to get back fuller billing information. We need to be able to send "Paid" invoices to customers who pay with Paypal, so we need to capture this information.


Viewing all articles
Browse latest Browse all 468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>