/**
  * Perform a checkOrder
  *
  * @param int    $id          order id
  * @param string $paymentCode payment option code
  *
  * @return void
  */
 public function checkOrder($id, $paymentCode)
 {
     global $xtPrice;
     $orderId = mysqli_real_escape_string(xtc_db_connect(), $_GET['oID']);
     $comments = $this->_getComments($orderId);
     // Don't update orderstatus if it is already updated to approved once.
     foreach ($comments as $comment) {
         if (strstr($comment, $this->_assembleOrderComment(self::APPROVED))) {
             $this->_showError("Klarna Status already updated and approved.");
             return;
         }
     }
     $ref = $this->_getRefNumber($orderId);
     if ($ref === null) {
         $this->_showError("No matching reference found for order id {$orderId}.");
         return;
     }
     KlarnaUtils::configureKiTT(KlarnaConstant::getKiTTOption($paymentCode));
     KlarnaUtils::configureKlarna(KlarnaConstant::getKiTTOption($paymentCode));
     $statusName = null;
     try {
         $statusName = $this->_getStatus(KiTT::api($this->_getOrderCountry()), $ref);
     } catch (Exception $e) {
         $this->_showError($e->getMessage() . " Is {$paymentCode} configured?");
     }
     if ($statusName === null) {
         return;
     }
     $newComment = $this->_assembleOrderComment($statusName);
     echo "<br /> {$newComment} <br />";
     $order_status_id = $this->_getPaymentStatusID($paymentCode, $statusName);
     $sql_data_arr = array('orders_id' => $orderId, 'orders_status_id' => $order_status_id, 'comments' => $newComment, 'customer_notified' => 0, 'date_added' => date("Y-m-d H:i:s"));
     $this->_klarnaDB->perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_arr);
     xtc_db_query("UPDATE " . TABLE_ORDERS . " SET orders_status='" . $order_status_id . "' WHERE orders_id='" . $orderId . "'");
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  * Takes information from GET and sends it to KlarnaAjax and
  * the Dispatcher.
  */
 public function __construct()
 {
     $country = $_GET['country'];
     $option = str_replace('klarna_box_', '', $_GET['type']);
     if ($option == 'special') {
         $option = 'spec';
     }
     KlarnaUtils::configureKiTT($option);
     KlarnaUtils::configureKlarna($option);
     $dispatcher = KiTT::ajaxDispatcher(new KiTT_Addresses(KiTT::api($country)), null);
     $dispatcher->dispatch();
 }