/** * @param Payone_Api_Response_Interface $response */ public function handle(Payone_Api_Response_Interface $response) { $address = $this->getAddress(); $errors = $this->getErrors(); $config = $this->getConfig(); $mapping = $config->getMappingPersonstatus(); if ($response instanceof Payone_Api_Response_AddressCheck_Valid) { /** @var $response Payone_Api_Response_AddressCheck_Valid */ if ($response->isCorrect()) { $this->handleCorrectAddress(); // Do nothing, best case, resume with personStatus mapping. } elseif ($response->isCorrectable()) { $correctedAddress = $this->prepareAddressCorrectionDataForCustomer($response); if ($correctedAddress['city'] == $address->getCity() && $correctedAddress['postcode'] == $address->getPostcode() && $correctedAddress['street'] == $address->getStreetFull()) { // PAYONE Api supports name correction, but it is not desired here, handle as a correct address. $this->handleCorrectAddress(); } elseif ($this->getConfig()->getConfirmAddressCorrection()) { // Address correction must be confirmed by customer, hand it up to controller/frontend $errors->setData('payone_address_corrected', $correctedAddress); } else { // Automatically correct address, allowing customer to resume checkout $this->correctAddress($response); } } $personStatus = $response->getPersonstatus(); if ($personStatus != 'NONE') { if (array_key_exists($personStatus, $mapping)) { $score = $mapping[$personStatus]; $address->setData('payone_addresscheck_score', $score); } } else { $score = 'G'; $address->setData('payone_addresscheck_score', $score); } $this->saveCustomerAddress($address); } elseif ($response instanceof Payone_Api_Response_AddressCheck_Invalid) { /** @var $response Payone_Api_Response_AddressCheck_Invalid */ $message = $this->getMessageForInvalidData($response->getCustomermessage()); $errors->setData('payone_address_invalid', $message); } elseif ($response instanceof Payone_Api_Response_Error) { /** @var $response Payone_Api_Response_Error */ $this->handleError(); } }