Page 1 of 1

Paypal Express address_2 modification

PostPosted: Tue Sep 27, 2016 2:57 pm
by admin
hello friends, we had released a patch for future VM versions (after 3.0.18) to include address_2 as returned by paypal:
https://www.rupostel.com/svn3/patch.1474980763.svn.txt

or you can manually modify:
\plugins\vmpayment\paypal\paypal\helpers\paypalexp.php


and locate and replace whole function with this:
Code: Select all
function storeAddresses () {
      $this->cart = VirtueMartCart::getCart();
      $addressST = $addressBT = array();
      if ($this->response['SHIPTONAME'] == $this->response['FIRSTNAME'] . ' ' . $this->response['LASTNAME']) {
         $firstName = $this->response['FIRSTNAME'];
         $lastName = $this->response['LASTNAME'];
      } else {
         $shipToName = explode(' ', $this->response['SHIPTONAME']);
         $firstName = $shipToName[0];
         $lastName = '';
         if (count($shipToName) > 1) {
            $lastName = str_replace($firstName . ' ', '', $this->response['SHIPTONAME']);
         }
      }
      // validateUserData > 0 => valid, -1 means only defaults are filled, 0 means it is not valid.
      $validateUserData=$this->cart->validateUserData();
      if ($validateUserData !== true) {
         $addressBT['email'] = $this->response['EMAIL'];
         $addressBT['first_name'] = $firstName;
         $addressBT['last_name'] = $lastName;
         $addressBT['address_1'] = $this->response['SHIPTOSTREET'];
         if (isset($this->response['PAYMENTREQUEST_0_SHIPTOSTREET2']))
         $addressBT['address_2'] = $this->response['PAYMENTREQUEST_0_SHIPTOSTREET2'];
         $addressBT['city'] = $this->response['SHIPTOCITY'];
         $addressBT['zip'] = $this->response['SHIPTOZIP'];
         $addressBT['virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']);
         $addressBT['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']);
         $this->cart->saveAddressInCart($addressBT, 'BT', true);
      }


      $addressST['shipto_address_type_name'] = 'PayPal Account';
      $addressST['shipto_first_name'] = $firstName;
      $addressST['shipto_last_name'] = $lastName;
      $addressST['shipto_address_1'] = $this->response['SHIPTOSTREET'];
      if (isset($this->response['PAYMENTREQUEST_0_SHIPTOSTREET2']))
      $addressST['shipto_address_2'] = $this->response['PAYMENTREQUEST_0_SHIPTOSTREET2'];
      $addressST['shipto_city'] = $this->response['SHIPTOCITY'];
      $addressST['shipto_zip'] = $this->response['SHIPTOZIP'];
      $addressST['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']);
      $addressST['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']);
      $this->cart->STsameAsBT = 0;
      $this->cart->setCartIntoSession();
      $this->cart->saveAddressInCart($addressST, 'ST', true,'shipto_');


   }



best regards, stan