Пример #1
0
 /**
  * Sets address data from exported address
  *
  * @param Address $address
  * @param array $addressData
  * @return void
  */
 private function updateAddressData(Address $address, array $addressData)
 {
     $extendedAddress = isset($addressData['extendedAddress']) ? $addressData['extendedAddress'] : null;
     $address->setStreet([$addressData['streetAddress'], $extendedAddress]);
     $address->setCity($addressData['locality']);
     $address->setRegionCode($addressData['region']);
     $address->setCountryId($addressData['countryCodeAlpha2']);
     $address->setPostcode($addressData['postalCode']);
 }
Пример #2
0
 /**
  * The billing address returned from Braintree may have different format than the shipping address
  *
  * @param Address $address
  * @param array $exportedAddress
  * @return $this
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function importBillingAddressData($address, $exportedAddress)
 {
     $line1 = isset($exportedAddress['streetAddress']) ? $exportedAddress['streetAddress'] : $exportedAddress['line1'];
     $line2 = isset($exportedAddress['extendedAddress']) ? $exportedAddress['extendedAddress'] : $exportedAddress['line2'];
     $city = isset($exportedAddress['locality']) ? $exportedAddress['locality'] : $exportedAddress['city'];
     $regionCode = isset($exportedAddress['region']) ? $exportedAddress['region'] : $exportedAddress['state'];
     $countryCode = isset($exportedAddress['countryCodeAlpha2']) ? $exportedAddress['countryCodeAlpha2'] : $exportedAddress['countryCode'];
     $address->setStreet([$line1, $line2]);
     $address->setCity($city);
     $address->setRegionCode($regionCode);
     $address->setCountryId($countryCode);
     $address->setPostcode($exportedAddress['postalCode']);
     return $this;
 }