bluepay_hosted.php (2467B)
1 <?php 2 3 class ModelExtensionPaymentBluePayHosted extends Model { 4 5 public function getMethod($address, $total) { 6 $this->load->language('extension/payment/bluepay_hosted'); 7 8 $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE geo_zone_id = '" . (int)$this->config->get('payment_bluepay_hosted_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); 9 10 if ($this->config->get('payment_bluepay_hosted_total') > 0 && $this->config->get('payment_bluepay_hosted_total') > $total) { 11 $status = false; 12 } elseif (!$this->config->get('payment_bluepay_hosted_geo_zone_id')) { 13 $status = true; 14 } elseif ($query->num_rows) { 15 $status = true; 16 } else { 17 $status = false; 18 } 19 20 $method_data = array(); 21 22 if ($status) { 23 $method_data = array( 24 'code' => 'bluepay_hosted', 25 'title' => $this->language->get('text_title'), 26 'terms' => '', 27 'sort_order' => $this->config->get('payment_bluepay_hosted_sort_order') 28 ); 29 } 30 31 return $method_data; 32 } 33 34 public function addOrder($order_info, $response_data) { 35 if ($this->config->get('payment_bluepay_hosted_transaction') == 'SALE') { 36 $release_status = 1; 37 } else { 38 $release_status = null; 39 } 40 41 $this->db->query("INSERT INTO `" . DB_PREFIX . "bluepay_hosted_order` SET `order_id` = '" . (int)$order_info['order_id'] . "', `transaction_id` = '" . $this->db->escape($response_data['RRNO']) . "', `date_added` = now(), `date_modified` = now(), `release_status` = '" . (int)$release_status . "', `currency_code` = '" . $this->db->escape($order_info['currency_code']) . "', `total` = '" . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false) . "'"); 42 43 return $this->db->getLastId(); 44 } 45 46 public function addTransaction($bluepay_hosted_order_id, $type, $order_info) { 47 $this->db->query("INSERT INTO `" . DB_PREFIX . "bluepay_hosted_order_transaction` SET `bluepay_hosted_order_id` = '" . (int)$bluepay_hosted_order_id . "', `date_added` = now(), `type` = '" . $this->db->escape($type) . "', `amount` = '" . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false) . "'"); 48 } 49 50 public function logger($message) { 51 if ($this->config->get('payment_bluepay_hosted_debug') == 1) { 52 $log = new Log('bluepay_hosted.log'); 53 $log->write($message); 54 } 55 } 56 57 }