realex.php (3070B)
1 <?php 2 class ModelExtensionPaymentRealex extends Model { 3 public function getMethod($address, $total) { 4 $this->load->language('extension/payment/realex'); 5 6 $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_realex_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); 7 8 if ($this->config->get('payment_realex_total') > 0 && $this->config->get('payment_realex_total') > $total) { 9 $status = false; 10 } elseif (!$this->config->get('payment_realex_geo_zone_id')) { 11 $status = true; 12 } elseif ($query->num_rows) { 13 $status = true; 14 } else { 15 $status = false; 16 } 17 18 $method_data = array(); 19 20 if ($status) { 21 $method_data = array( 22 'code' => 'realex', 23 'title' => $this->language->get('text_title'), 24 'terms' => '', 25 'sort_order' => $this->config->get('payment_realex_sort_order') 26 ); 27 } 28 29 return $method_data; 30 } 31 32 public function addOrder($order_info, $pas_ref, $auth_code, $account, $order_ref) { 33 if ($this->config->get('payment_realex_auto_settle') == 1) { 34 $settle_status = 1; 35 } else { 36 $settle_status = 0; 37 } 38 39 $this->db->query("INSERT INTO `" . DB_PREFIX . "realex_order` SET `order_id` = '" . (int)$order_info['order_id'] . "', `settle_type` = '" . (int)$this->config->get('payment_realex_auto_settle') . "', `order_ref` = '" . $this->db->escape($order_ref) . "', `order_ref_previous` = '" . $this->db->escape($order_ref) . "', `date_added` = now(), `date_modified` = now(), `capture_status` = '" . (int)$settle_status . "', `currency_code` = '" . $this->db->escape($order_info['currency_code']) . "', `pasref` = '" . $this->db->escape($pas_ref) . "', `pasref_previous` = '" . $this->db->escape($pas_ref) . "', `authcode` = '" . $this->db->escape($auth_code) . "', `account` = '" . $this->db->escape($account) . "', `total` = '" . $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) . "'"); 40 41 return $this->db->getLastId(); 42 } 43 44 public function addTransaction($realex_order_id, $type, $order_info) { 45 $this->db->query("INSERT INTO `" . DB_PREFIX . "realex_order_transaction` SET `realex_order_id` = '" . (int)$realex_order_id . "', `date_added` = now(), `type` = '" . $this->db->escape($type) . "', `amount` = '" . $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) . "'"); 46 } 47 48 public function addHistory($order_id, $order_status_id, $comment) { 49 $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '0', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); 50 } 51 52 public function logger($message) { 53 if ($this->config->get('payment_realex_debug') == 1) { 54 $log = new Log('realex.log'); 55 $log->write($message); 56 } 57 } 58 }