/**
  * Transfer data from an address validation address to a customer address.
  *
  * @param CustomerAddressInterface
  * @param AddressInterface|null
  * @return CustomerAddressInterface
  */
 public function transferDataAddressToCustomerAddress(CustomerAddressInterface $customerAddress, AddressInterface $dataAddress = null)
 {
     if ($dataAddress) {
         $region = $customerAddress->getRegion();
         $region->setRegionCode($dataAddress->getRegionCode())->setRegionId($dataAddress->getRegionId())->setRegion($dataAddress->getRegionName());
         $customerAddress->setStreet($dataAddress->getStreet())->setCity($dataAddress->getCity())->setCountryId($dataAddress->getCountryId())->setPostcode($dataAddress->getPostcode())->setRegion($region);
     }
     return $customerAddress;
 }
 /**
  * Compare two addresses to have the same data.
  *
  * @param AddressInterface|null
  * @param AddressInterface|null
  * @return bool
  */
 public function compareAddresses(AddressInterface $a = null, AddressInterface $b = null)
 {
     // If either is null, cannot be matching addresses.
     if (!$a || !$b) {
         return false;
     }
     return $a->getStreet() === $b->getStreet() && $a->getCity() === $b->getCity() && $a->getRegionCode() === $b->getRegionCode() && $a->getPostcode() === $b->getPostcode() && $a->getCountryId() === $b->getCountryId();
 }
 public function getAddressHtml(AddressInterface $address)
 {
     return sprintf('%s<br/>%s %s %s %s', implode('<br/>', $address->getStreet()), $address->getCity(), $address->getRegionCode(), $address->getCountryId(), $address->getPostcode());
 }
 /**
  * Transfer the SDK payload data to a Magento address object.
  *
  * @param IPhysicalAddress
  * @param AddressInterface
  * @return AddressInterface
  */
 public function transferPhysicalAddressPayloadToAddress(IPhysicalAddress $addressPayload, AddressInterface $address)
 {
     $region = $this->regionHelper->loadRegion(null, $addressPayload->getMainDivision(), null, $addressPayload->getCountryCode());
     return $address->setStreet(explode("\n", $addressPayload->getLines()))->setCity($addressPayload->getCity())->setCountryId($addressPayload->getCountryCode())->setRegionCode($region->getCode())->setRegionId($region->getId())->setRegionName($region->getName())->setPostcode($addressPayload->getPostalCode());
 }