/** * 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 . "'"); }
/** * 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(); }
/** * Setup the payment module for usage. * * @return void */ protected function setupModule() { global $order; KlarnaUtils::configureKlarna($this->_option); if ($this->_country === null) { return; } // Pass the api instance to the utils object. $this->_utils->setApi(KiTT::api($this->_locale->getCountry())); $this->_totalSum = $this->_utils->getCartSum(); $this->order_status = KlarnaConstant::getOrderStatusId($this->_option); // if order is an object instead of an array, we're returning after // a purchase. Then we want to call update_status. if (is_object($order)) { $this->update_status(); } $this->form_action_url = xtc_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false); }