/** * Extract any address suggestions from the address validation response, * storing them as an array of Magento address models. * * @return self */ protected function extractAddressSuggestions(IValidationReply $response) { $suggestionAddresses = []; foreach ($response->getSuggestedAddresses() as $physicalAddress) { $address = Mage::getModel('customer/address', ['has_been_validated' => true]); $this->helper->transferPhysicalAddressPayloadToAddress($physicalAddress, $address); $suggestionAddresses[] = $address; } return $this->setData('address_suggestions', $suggestionAddresses); }
/** * Send the request and parse the response. * * @param Mage_Customer_Model_Address_Abstract $address * @param string $errorMessage * @return EbayEnterprise_Address_Model_Validation_Response|null */ protected function _processRequest(Mage_Customer_Model_Address_Abstract $address, &$errorMessage) { $response = $this->_makeRequestForAddress($address); if ($response) { // copy over validated address data if ($response->isAddressValid()) { $address->addData($response->getValidAddress()->getData()); } else { $address->addData($response->getOriginalAddress()->getData()); if ($address->getSameAsBilling()) { $address->setSameAsBilling(false); } $errorMessage = ''; if ($response->getHasSuggestions()) { $errorMessage = $this->_helper->__(self::SUGGESTIONS_ERROR_MESSAGE); } else { $errorMessage = $this->_helper->__(self::NO_SUGGESTIONS_ERROR_MESSAGE); } } } return $response; }
/** * Prepare the request payload - inject address and validation header data. * * @return self */ public function prepareRequest() { $this->_helper->transferAddressToPhysicalAddressPayload($this->_address, $this->_requestPayload->setMaxSuggestions($this->_helper->getConfigModel()->maxAddressSuggestions)); return $this; }