/**
  * Match an address from the checkout with an address from getAddress, and
  * return the matching address.
  *
  * @param array  &$errors reference to errors array
  * @param string $option  payment method
  *
  * @return object KlarnaAddr object
  */
 public function getMatchingAddress(&$errors, $option)
 {
     $addrs = array();
     $pno = $_POST["klarna_{$option}_pno"];
     $_SESSION['klarna_data']['pno'] = $pno;
     $_SESSION['klarna_data']['phone'] = $_POST["klarna_{$option}_phone_number"];
     $address = new KlarnaAddr();
     $KITTaddr = new KiTT_Addresses(KiTT::api('SE'));
     try {
         $address = $KITTaddr->getMatchingAddress($pno, $_POST["klarna_{$option}_address_key"]);
         $address->setTelno($_POST["klarna_{$option}_phone_number"]);
         $address->setCellno($_POST["klarna_{$option}_phone_number"]);
         $address->setEmail($_POST["klarna_email"]);
     } catch (Exception $e) {
         Klarna::printDebug('Error in __METHOD__', $e->getMessage());
         $errors[] = "error_no_address";
     }
     return $address;
 }
 /**
  * Populate an array with customer information
  *
  * @param object $order osCommerce order object
  *
  * @return array
  */
 public function collectKlarnaData($order)
 {
     $klarna_data = array();
     $klarna_data['phone_number'] = $order->customer['telephone'];
     $klarna_data['email_address'] = $order->customer['email_address'];
     $klarna_data['reference'] = $order->delivery['firstname'] . " " . $order->delivery['lastname'];
     $address = KiTT_Addresses::splitStreet($order->delivery['street_address'], $this->_country);
     $klarna_data = array_merge($klarna_data, $address);
     if (KiTT_CountryLogic::needDateOfBirth($this->_country)) {
         // Get date of birth
         $customer_query = $this->_klarnaDB->query("SELECT DATE_FORMAT(customers_dob, " . "'%d%m%Y') AS customers_dob from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $_SESSION['customer_id'] . "'");
         $customer = $customer_query->getArray();
         $dob = $customer['customers_dob'];
         $klarna_data['birth_year'] = substr($dob, 4, 4);
         $klarna_data['birth_month'] = substr($dob, 2, 2);
         $klarna_data['birth_day'] = substr($dob, 0, 2);
     }
     $klarna_data['first_name'] = $order->delivery['firstname'];
     $klarna_data['last_name'] = $order->delivery['lastname'];
     $klarna_data['city'] = $order->delivery['city'];
     $klarna_data['zipcode'] = $order->delivery['postcode'];
     $klarna_data['company_name'] = $order->delivery['company'];
     $klarna_data['gender'] = $order->customer['gender'] == 'm' ? 1 : 0;
     foreach ($klarna_data as $key => $value) {
         $klarna_data[$key] = KiTT_String::encode($value, null, 'UTF-8');
     }
     return $klarna_data;
 }
예제 #3
0
 /**
  * Make a get_addresses call to KRED for the pno in GET/POST
  *
  * @return array containing content and content-type
  */
 public function getAddress()
 {
     $addrs = $this->_addresses->getAddresses(KiTT_HTTPContext::toString('pno'));
     return array('type' => 'application/json', 'value' => $this->_getAddressesJson($addrs));
 }