/** * Convert magento address to array for braintree * * @param \Magento\Sales\Api\Data\OrderAddressInterface $address * @return array */ public function toBraintreeAddress($address) { if ($address) { $countryId = $address->getCountryId(); $region = $address->getRegion(); if ($countryId == 'US') { $region = $this->convertRegionToCode($region, $address->getRegionId()); } $street = $address->getStreet(); $streetAddress = $street[0]; return ['firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'company' => $address->getCompany(), 'streetAddress' => $streetAddress, 'extendedAddress' => isset($street[1]) ? $street[1] : null, 'locality' => $address->getCity(), 'region' => $region, 'postalCode' => $address->getPostcode(), 'countryCodeAlpha2' => $countryId]; } else { return []; } }
/** * Get last name * * @return string */ public function getLastname() { return $this->address->getLastname(); }