[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/payment/ -> paybox.php (source)

   1  <?php
   2  /*

   3    Contribution by Emmanuel Alliel <[email protected]>

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    class paybox {
  14      var $code, $title, $description, $enabled;
  15  
  16  // class constructor

  17      function paybox() {
  18        global $order;
  19  
  20        $this->code = 'paybox';
  21        $this->title = MODULE_PAYMENT_PAYBOX_TEXT_TITLE;
  22        $this->description = MODULE_PAYMENT_PAYBOX_TEXT_DESCRIPTION;
  23        $this->sort_order = MODULE_PAYMENT_PAYBOX_SORT_ORDER;
  24        $this->enabled = ((MODULE_PAYMENT_PAYBOX_STATUS == 'True') ? true : false);
  25  
  26        if ((int)MODULE_PAYMENT_PAYBOX_ORDER_STATUS_ID > 0) {
  27          $this->order_status = MODULE_PAYMENT_PAYBOX_ORDER_STATUS_ID;
  28        }
  29  
  30        if (is_object($order)) $this->update_status();
  31  
  32        $this->form_action_url = MODULE_PAYMENT_PAYBOX_CGI;
  33      }
  34  
  35  // class methods

  36      function update_status() {
  37        global $order;
  38  
  39        if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYBOX_ZONE > 0) ) {
  40          $check_flag = false;
  41          $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYBOX_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
  42          while ($check = tep_db_fetch_array($check_query)) {
  43            if ($check['zone_id'] < 1) {
  44              $check_flag = true;
  45              break;
  46            } elseif ($check['zone_id'] == $order->billing['zone_id']) {
  47              $check_flag = true;
  48              break;
  49            }
  50          }
  51  
  52          if ($check_flag == false) {
  53            $this->enabled = false;
  54          }
  55        }
  56      }
  57  
  58      function javascript_validation() {
  59        return false;
  60      }
  61  
  62      function selection() {
  63        return array('id' => $this->code,
  64                     'module' => $this->title);
  65      }
  66  
  67      function pre_confirmation_check() {
  68        return false;
  69      }
  70  
  71      function confirmation() {
  72        return false;
  73      }
  74  
  75      function process_button() {
  76        global $order;
  77  
  78        $process_button_string = tep_draw_hidden_field('IBS_MODE', '1') .
  79                                 tep_draw_hidden_field('IBS_SITE', '1999888') .
  80                                 tep_draw_hidden_field('IBS_RANG', '99') .
  81                                 tep_draw_hidden_field('IBS_TOTAL', $order->info['total'] * 100) .
  82                                 tep_draw_hidden_field('IBS_DEVISE', '978') .
  83                                    tep_draw_hidden_field('IBS_CMD', $order->customer['email_address'] . '|' . $order->info['total']) .
  84                             tep_draw_hidden_field('IBS_PORTEUR', $order->customer['email_address']) .
  85                                 tep_draw_hidden_field('IBS_RETOUR', 'IBS_TOTAL:M;IBS_CMD:R;auto:A;trans:T') .
  86      tep_draw_hidden_field('IBS_ANNULE', tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true)) .
  87      tep_draw_hidden_field('IBS_REFUSE', tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true)) .
  88                                 tep_draw_hidden_field('IBS_EFFECTUE', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) .
  89                                 tep_draw_hidden_field(tep_session_name(), tep_session_id()) .
  90                                 tep_draw_hidden_field('options', 'test_status=' . $test_status . ',dups=false,cb_post=true,cb_flds=' . tep_session_name());
  91  
  92        return $process_button_string;
  93      }
  94  
  95      function before_process() {
  96        global $HTTP_POST_VARS;
  97  
  98        if ($HTTP_POST_VARS['valid'] == 'true') {
  99          if ($remote_host = getenv('REMOTE_HOST')) {
 100            if ($remote_host != 'paybox.com') {
 101              $remote_host = gethostbyaddr($remote_host);
 102            }
 103            if ($remote_host != 'paybox.com') {
 104              tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&payment_error=' . $this->code, 'SSL', false, false));
 105            }
 106          } else {
 107            tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&payment_error=' . $this->code, 'SSL', false, false));
 108          }
 109        }
 110      }
 111  
 112      function after_process() {
 113        return false;
 114      }
 115  
 116      function get_error() {
 117        global $HTTP_GET_VARS;
 118  
 119        if (isset($HTTP_GET_VARS['message']) && (strlen($HTTP_GET_VARS['message']) > 0)) {
 120          $error = stripslashes(urldecode($HTTP_GET_VARS['message']));
 121        } else {
 122          $error = MODULE_PAYMENT_PAYBOX_TEXT_ERROR_MESSAGE;
 123        }
 124  
 125        return array('title' => MODULE_PAYMENT_PAYBOX_TEXT_ERROR,
 126                     'error' => $error);
 127      }
 128  
 129      function check() {
 130        if (!isset($this->_check)) {
 131          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYBOX_STATUS'");
 132          $this->_check = tep_db_num_rows($check_query);
 133        }
 134        return $this->_check;
 135      }
 136  
 137      function install() {
 138        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Paybox Module', 'MODULE_PAYMENT_PAYBOX_STATUS', 'True', 'Activer ce module Paybox ?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
 139        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('IBS_SITE', 'MODULE_PAYMENT_PAYBOX_IBS_SITE', '1999888', 'IBS_SITE fournit par Paybox', '6', '2', now())");
 140        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('IBS_RANG', 'MODULE_PAYMENT_PAYBOX_IBS_RANG', '99', 'IBS_RANG fournit par Paybox', '6', '3', now())");
 141        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('CGI Path', 'MODULE_PAYMENT_PAYBOX_CGI', 'http://www.maboutique.biz/cgi-bin/paybox.cgi', 'Chemin de votre module CGI fournit par Paybox', '6', '4', now())");
 142        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYBOX_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
 143        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYBOX_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
 144        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_PAYBOX_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
 145      }
 146  
 147      function remove() {
 148        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 149      }
 150  
 151      function keys() {
 152        return array('MODULE_PAYMENT_PAYBOX_STATUS', 'MODULE_PAYMENT_PAYBOX_IBS_SITE', 'MODULE_PAYMENT_PAYBOX_IBS_RANG', 'MODULE_PAYMENT_PAYBOX_CGI', 'MODULE_PAYMENT_PAYBOX_ZONE', 'MODULE_PAYMENT_PAYBOX_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYBOX_SORT_ORDER');
 153      }
 154    }
 155  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7