/**
  * 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;
 }
 /**
  * This function implements any checks of any conditions after payment
  * method has been selected.
  *
  * @return void
  */
 public function preConfirmationCheck()
 {
     global $order;
     $addressHandler = new KlarnaAddressXtc();
     $this->_utils->cleanPost();
     $this->_addrs = $this->_utils->handlePost($this->_option);
     if ($this->_isPart() || $this->_isSpec()) {
         $this->_paymentPlan = $_SESSION['klarna_paymentPlan'] = (int) $_POST["klarna_{$this->_option}_paymentPlan"];
     } else {
         $this->_paymentPlan = -1;
     }
     $order->delivery = array_merge($order->delivery, $addressHandler->klarnaAddrToXtcAddr($this->_addrs));
     if (KiTT_CountryLogic::shippingSameAsBilling($this->_country)) {
         $order->billing = $order->delivery;
     }
     $_SESSION['klarna_data']['serial_addr'] = serialize($this->_addrs);
 }