shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

globalpay.php (3121B)


      1 <?php
      2 class ModelExtensionPaymentGlobalpay extends Model {
      3 	public function getMethod($address, $total) {
      4 		$this->load->language('extension/payment/globalpay');
      5 
      6 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_globalpay_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_globalpay_total') > 0 && $this->config->get('payment_globalpay_total') > $total) {
      9 			$status = false;
     10 		} elseif (!$this->config->get('payment_globalpay_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'       => 'globalpay',
     23 				'title'      => $this->language->get('text_title'),
     24 				'terms'      => '',
     25 				'sort_order' => $this->config->get('payment_globalpay_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_globalpay_auto_settle') == 1) {
     34 			$settle_status = 1;
     35 		} else {
     36 			$settle_status = 0;
     37 		}
     38 
     39 		$this->db->query("INSERT INTO `" . DB_PREFIX . "globalpay_order` SET `order_id` = '" . (int)$order_info['order_id'] . "', `settle_type` = '" . (int)$this->config->get('payment_globalpay_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($globalpay_order_id, $type, $order_info) {
     45 		$this->db->query("INSERT INTO `" . DB_PREFIX . "globalpay_order_transaction` SET `globalpay_order_id` = '" . (int)$globalpay_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_globalpay_debug') == 1) {
     54 			$log = new Log('globalpay.log');
     55 			$log->write($message);
     56 		}
     57 	}
     58 }