/** * Handle the $_POST variable and return a KlarnaAddr object * * @param string $option payment option, invoice, part or spec * * @return KlarnaAddr address object */ public function handlePost($option) { $addrHandler = new KlarnaAddressXtc(); $errors = array(); $lang = self::getLanguageCode(); $address = new KlarnaAddr(); if (strtolower($this->_country) == 'se') { try { $address = $addrHandler->getMatchingAddress($errors, $option); } catch (Exception $e) { $this->setError(htmlentities($e->getMessage()) . " (#" . $e->getCode() . ")", $option); xtc_redirect($this->errorLink(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false)); } } if (strtolower($this->_country) != "se") { try { $aKlarnaAddress = $addrHandler->addressArrayFromPost($option); $address = $addrHandler->buildKlarnaAddressFromArray($aKlarnaAddress, $this->_country); } catch (Exception $e) { $this->setError(htmlentities($e->getMessage()) . " (#" . $e->getCode() . ")", $option); xtc_redirect($this->errorLink(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false)); } $_SESSION['klarna_data'] = $aKlarnaAddress; if (KiTT_CountryLogic::needConsent($this->_country) && $_POST["klarna_{$option}_consent"] != 'consent') { $errors[] = "no_consent"; } if (KiTT_CountryLogic::needDateOfBirth($this->_country)) { $_SESSION['klarna_data']["pno"] = $_POST["klarna_{$option}_birth_day"] . $_POST["klarna_{$option}_birth_month"] . $_POST["klarna_{$option}_birth_year"]; $_SESSION['klarna_data']['gender'] = $_POST["klarna_{$option}_gender"]; } } if (!empty($errors)) { foreach ($errors as $err) { $translated[] = $this->translate($err, $lang); } $this->setError(htmlentities(implode(',', $translated), ENT_COMPAT, 'UTF-8'), $option); xtc_redirect($this->errorLink(FILENAME_CHECKOUT_PAYMENT, "", "SSL")); } return $address; }