[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

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

   1  <?php
   2  /*

   3  $Id: secpay.php 3 2006-05-27 04:59:07Z user $

   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 secpay {
  14      var $code, $title, $description, $enabled;
  15  
  16  // class constructor

  17      function secpay() {
  18        global $order;
  19  
  20        $this->code = 'secpay';
  21        $this->title = MODULE_PAYMENT_SECPAY_TEXT_TITLE;
  22        $this->description = MODULE_PAYMENT_SECPAY_TEXT_DESCRIPTION;
  23        $this->sort_order = MODULE_PAYMENT_SECPAY_SORT_ORDER;
  24        $this->enabled = ((MODULE_PAYMENT_SECPAY_STATUS == 'True') ? true : false);
  25  
  26        if ((int)MODULE_PAYMENT_SECPAY_ORDER_STATUS_ID > 0) {
  27          $this->order_status = MODULE_PAYMENT_SECPAY_ORDER_STATUS_ID;
  28        }
  29  
  30        if (is_object($order)) $this->update_status();
  31  
  32        $this->form_action_url = 'https://www.secpay.com/java-bin/ValCard';
  33      }
  34  
  35  // class methods

  36      function update_status() {
  37        global $order;
  38  
  39        if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_SECPAY_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_SECPAY_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, $currencies, $currency;
  77  
  78        switch (MODULE_PAYMENT_SECPAY_CURRENCY) {
  79          case 'Default Currency':
  80            $sec_currency = DEFAULT_CURRENCY;
  81            break;
  82          case 'Any Currency':
  83          default:
  84            $sec_currency = $currency;
  85            break;
  86        }
  87  
  88        switch (MODULE_PAYMENT_SECPAY_TEST_STATUS) {
  89          case 'Always Fail':
  90            $test_status = 'false';
  91            break;
  92          case 'Production':
  93            $test_status = 'live';
  94            break;
  95          case 'Always Successful':
  96          default:
  97            $test_status = 'true';
  98            break;
  99        }
 100  
 101        $process_button_string = tep_draw_hidden_field('merchant', MODULE_PAYMENT_SECPAY_MERCHANT_ID) .
 102                                 tep_draw_hidden_field('trans_id', STORE_NAME . date('Ymdhis')) .
 103                                 tep_draw_hidden_field('amount', number_format($order->info['total'] * $currencies->get_value($sec_currency), $currencies->currencies[$sec_currency]['decimal_places'], '.', '')) .
 104                                 tep_draw_hidden_field('bill_name', $order->billing['firstname'] . ' ' . $order->billing['lastname']) .
 105                                 tep_draw_hidden_field('bill_addr_1', $order->billing['street_address']) .
 106                                 tep_draw_hidden_field('bill_addr_2', $order->billing['suburb']) .
 107                                 tep_draw_hidden_field('bill_city', $order->billing['city']) .
 108                                 tep_draw_hidden_field('bill_state', $order->billing['state']) .
 109                                 tep_draw_hidden_field('bill_post_code', $order->billing['postcode']) .
 110                                 tep_draw_hidden_field('bill_country', $order->billing['country']['title']) .
 111                                 tep_draw_hidden_field('bill_tel', $order->customer['telephone']) .
 112                                 tep_draw_hidden_field('bill_email', $order->customer['email_address']) .
 113                                 tep_draw_hidden_field('ship_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) .
 114                                 tep_draw_hidden_field('ship_addr_1', $order->delivery['street_address']) .
 115                                 tep_draw_hidden_field('ship_addr_2', $order->delivery['suburb']) .
 116                                 tep_draw_hidden_field('ship_city', $order->delivery['city']) .
 117                                 tep_draw_hidden_field('ship_state', $order->delivery['state']) .
 118                                 tep_draw_hidden_field('ship_post_code', $order->delivery['postcode']) .
 119                                 tep_draw_hidden_field('ship_country', $order->delivery['country']['title']) .
 120                                 tep_draw_hidden_field('currency', $sec_currency) .
 121                                 tep_draw_hidden_field('callback', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false) . ';' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL', false)) .
 122                                 tep_draw_hidden_field(tep_session_name(), tep_session_id()) .
 123                                 tep_draw_hidden_field('options', 'test_status=' . $test_status . ',dups=false,cb_post=true,cb_flds=' . tep_session_name());
 124  
 125        return $process_button_string;
 126      }
 127  
 128      function before_process() {
 129        global $HTTP_POST_VARS;
 130  
 131        if ($HTTP_POST_VARS['valid'] == 'true') {
 132          if ($remote_host = getenv('REMOTE_HOST')) {
 133            if ($remote_host != 'secpay.com') {
 134              $remote_host = gethostbyaddr($remote_host);
 135            }
 136            if ($remote_host != 'secpay.com') {
 137              tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&payment_error=' . $this->code, 'SSL', false, false));
 138            }
 139          } else {
 140            tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&payment_error=' . $this->code, 'SSL', false, false));
 141          }
 142        }
 143      }
 144  
 145      function after_process() {
 146        return false;
 147      }
 148  
 149      function get_error() {
 150        global $HTTP_GET_VARS;
 151  
 152        if (isset($HTTP_GET_VARS['message']) && (strlen($HTTP_GET_VARS['message']) > 0)) {
 153          $error = stripslashes(urldecode($HTTP_GET_VARS['message']));
 154        } else {
 155          $error = MODULE_PAYMENT_SECPAY_TEXT_ERROR_MESSAGE;
 156        }
 157  
 158        return array('title' => MODULE_PAYMENT_SECPAY_TEXT_ERROR,
 159                     'error' => $error);
 160      }
 161  
 162      function check() {
 163        if (!isset($this->_check)) {
 164          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_SECPAY_STATUS'");
 165          $this->_check = tep_db_num_rows($check_query);
 166        }
 167        return $this->_check;
 168      }
 169  
 170      function install() {
 171        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 SECpay Module', 'MODULE_PAYMENT_SECPAY_STATUS', 'True', 'Do you want to accept SECPay payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
 172        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant ID', 'MODULE_PAYMENT_SECPAY_MERCHANT_ID', 'secpay', 'Merchant ID to use for the SECPay service', '6', '2', now())");
 173        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 ('Transaction Currency', 'MODULE_PAYMENT_SECPAY_CURRENCY', 'Any Currency', 'The currency to use for credit card transactions', '6', '3', 'tep_cfg_select_option(array(\'Any Currency\', \'Default Currency\'), ', now())");
 174        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 ('Transaction Mode', 'MODULE_PAYMENT_SECPAY_TEST_STATUS', 'Always Successful', 'Transaction mode to use for the SECPay service', '6', '4', 'tep_cfg_select_option(array(\'Always Successful\', \'Always Fail\', \'Production\'), ', now())");
 175        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_SECPAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
 176        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_SECPAY_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())");
 177        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_SECPAY_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())");
 178      }
 179  
 180      function remove() {
 181        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 182      }
 183  
 184      function keys() {
 185        return array('MODULE_PAYMENT_SECPAY_STATUS', 'MODULE_PAYMENT_SECPAY_MERCHANT_ID', 'MODULE_PAYMENT_SECPAY_CURRENCY', 'MODULE_PAYMENT_SECPAY_TEST_STATUS', 'MODULE_PAYMENT_SECPAY_ZONE', 'MODULE_PAYMENT_SECPAY_ORDER_STATUS_ID', 'MODULE_PAYMENT_SECPAY_SORT_ORDER');
 186      }
 187    }
 188  ?>


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