Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

434
 
486
 
486
 
payment.php
_> 11 <?php
  22 /*
<> 3 -  $Id: payment.php 434 2006-02-15 20:49:45Z hpdl $
   3+  $Id: payment.php 486 2006-04-17 23:39:28Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
     
 !
1010   Released under the GNU General Public License
  1111 */
  1212 
<>  13+  include(dirname(__FILE__) . '/credit_card.php');
   14+
1315   class osC_Payment {
  1416     var $selected_module;
  1517 
     
 !
5658     }
  5759 
  5860 // class methods
<>  61+    function sendTransactionToGateway($url, $parameters, $header='', $method='post') {
   62+      if (empty($header) || (is_array($header) === false)) {
   63+        $header = array();
   64+      }
   65+
   66+      $result = '';
   67+
   68+      $server = parse_url($url);
   69+
   70+      if (isset($server['port']) === false) {
   71+        $server['port'] = ($server['scheme'] == 'https') ? 443 : 80;
   72+      }
   73+
   74+      if (isset($server['path']) === false) {
   75+        $server['path'] = '/';
   76+      }
   77+
   78+      if (isset($server['user']) && isset($server['pass'])) {
   79+        $header[] = 'Authorization: Basic ' . base64_encode($server['user'] . ':' . $server['pass']);
   80+      }
   81+
   82+
   83+      $curl = curl_init($server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : ''));
   84+      curl_setopt($curl, CURLOPT_PORT, $server['port']);
   85+
   86+      if (empty($header) === false) {
   87+        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
   88+      }
   89+
   90+      curl_setopt($curl, CURLOPT_HEADER, 0);
   91+      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
   92+      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   93+      curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
   94+      curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
   95+      curl_setopt($curl, CURLOPT_POST, 1);
   96+      curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);
   97+      $result = curl_exec($curl);
   98+      curl_close($curl);
   99+
   100+/*
   101+      exec('/usr/bin/curl -d ' . escapeshellarg($parameters) . ' "' . $server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '') . '" -P ' . $server['port'] . ' -k ' . (empty($header) === false ? '-H ' . escapeshellarg(implode("\r\n", $header)) : ''), $result);
   102+      $result = implode("\n", $result);
   103+*/
   104+/*
   105+      if ($fp = @fsockopen(($server['scheme'] == 'https' ? 'ssl' : $server['scheme']) . '://' . $server['host'], $server['port'])) {
   106+        @fputs($fp, 'POST ' . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '') . ' HTTP/1.1' . "\r\n" .
   107+                    'Host: ' . $server['host'] . "\r\n" .
   108+                    'Content-type: application/x-www-form-urlencoded' . "\r\n" .
   109+                    'Content-length: ' . strlen($parameters) . "\r\n" .
   110+                    (empty($header) === false ? implode("\r\n", $header) . "\r\n" : '') .
   111+                    'Connection: close' . "\r\n\r\n" .
   112+                    $parameters . "\r\n\r\n");
   113+
   114+        $result = @stream_get_contents($fp);
   115+
   116+        @fclose($fp);
   117+
   118+        $result = trim(substr($result, strpos($result, "\r\n\r\n", strpos(strtolower($result), 'content-length:'))));
   119+      }
   120+*/
   121+
   122+      return $result;
   123+    }
   124+
59125     function getCode() {
  60126       return $this->_code;
  61127     }
     
 !
68134       return $this->_description;
  69135     }
  70136 
<> 71 -    function getStatus() {
   137+    function getMethodTitle() {
   138+      return $this->_method_title;
   139+    }
   140+
   141+    function isEnabled() {
72142       return $this->_status;
  73143     }
  74144 
     
 !
104174               '  var error = 0;' . "\n" .
  105175               '  var error_message = "' . $osC_Language->get('js_error') . '";' . "\n" .
  106176               '  var payment_value = null;' . "\n" .
<> 107 -              '  if (document.checkout_payment.payment.length) {' . "\n" .
  108 -              '    for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" .
  109 -              '      if (document.checkout_payment.payment[i].checked) {' . "\n" .
  110 -              '        payment_value = document.checkout_payment.payment[i].value;' . "\n" .
   177+              '  if (document.checkout_payment.payment_method.length) {' . "\n" .
   178+              '    for (var i=0; i<document.checkout_payment.payment_method.length; i++) {' . "\n" .
   179+              '      if (document.checkout_payment.payment_method[i].checked) {' . "\n" .
   180+              '        payment_value = document.checkout_payment.payment_method[i].value;' . "\n" .
111181               '      }' . "\n" .
  112182               '    }' . "\n" .
<> 113 -              '  } else if (document.checkout_payment.payment.checked) {' . "\n" .
  114 -              '    payment_value = document.checkout_payment.payment.value;' . "\n" .
  115 -              '  } else if (document.checkout_payment.payment.value) {' . "\n" .
  116 -              '    payment_value = document.checkout_payment.payment.value;' . "\n" .
   183+              '  } else if (document.checkout_payment.payment_method.checked) {' . "\n" .
   184+              '    payment_value = document.checkout_payment.payment_method.value;' . "\n" .
   185+              '  } else if (document.checkout_payment.payment_method.value) {' . "\n" .
   186+              '    payment_value = document.checkout_payment.payment_method.value;' . "\n" .
117187               '  }' . "\n\n";
  118188 
  119189         foreach ($this->_modules as $module) {
<> 120 -          if ($GLOBALS['osC_Payment_' . $module]->getStatus() === true) {
   190+          if ($GLOBALS['osC_Payment_' . $module]->isEnabled()) {
121191             $js .= $GLOBALS['osC_Payment_' . $module]->javascript_validation();
  122192           }
  123193         }
     
 !
143213       $selection_array = array();
  144214 
  145215       foreach ($this->_modules as $module) {
<> 146 -        if ($GLOBALS['osC_Payment_' . $module]->getStatus() === true) {
   216+        if ($GLOBALS['osC_Payment_' . $module]->isEnabled()) {
147217           $selection = $GLOBALS['osC_Payment_' . $module]->selection();
  148218           if (is_array($selection)) $selection_array[] = $selection;
  149219         }
     
 !
154224 
  155225     function pre_confirmation_check() {
  156226       if (is_array($this->_modules)) {
<> 157 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   227+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
158228           $GLOBALS[$this->selected_module]->pre_confirmation_check();
  159229         }
  160230       }
  161231     }
  162232 
  163233     function confirmation() {
  164234       if (is_array($this->_modules)) {
<> 165 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   235+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
166236           return $GLOBALS[$this->selected_module]->confirmation();
  167237         }
  168238       }
  169239     }
  170240 
  171241     function process_button() {
  172242       if (is_array($this->_modules)) {
<> 173 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   243+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
174244           return $GLOBALS[$this->selected_module]->process_button();
  175245         }
  176246       }
  177247     }
  178248 
  179249     function before_process() {
  180250       if (is_array($this->_modules)) {
<> 181 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   251+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
182252           return $GLOBALS[$this->selected_module]->before_process();
  183253         }
  184254       }
  185255     }
  186256 
  187257     function after_process() {
  188258       if (is_array($this->_modules)) {
<> 189 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   259+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
190260           return $GLOBALS[$this->selected_module]->after_process();
  191261         }
  192262       }
  193263     }
  194264 
  195265     function get_error() {
  196266       if (is_array($this->_modules)) {
<> 197 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   267+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
198268           return $GLOBALS[$this->selected_module]->get_error();
  199269         }
  200270       }
  201271     }
  202272 
  203273     function hasActionURL() {
  204274       if (is_array($this->_modules)) {
<> 205 -        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->getStatus() === true) ) {
   275+        if (is_object($GLOBALS[$this->selected_module]) && $GLOBALS[$this->selected_module]->isEnabled()) {
206276           if (isset($GLOBALS[$this->selected_module]->form_action_url) && (empty($GLOBALS[$this->selected_module]->form_action_url) === false)) {
  207277             return true;
  208278           }
     
 !
223293         $has_active = false;
  224294 
  225295         foreach ($this->_modules as $module) {
<> 226 -          if ($GLOBALS['osC_Payment_' . $module]->getStatus() === true) {
   296+          if ($GLOBALS['osC_Payment_' . $module]->isEnabled()) {
227297             $has_active = true;
  228298             break;
  229299           }
     
 !
240310         $active = 0;
  241311 
  242312         foreach ($this->_modules as $module) {
<> 243 -          if ($GLOBALS['osC_Payment_' . $module]->getStatus() === true) {
   313+          if ($GLOBALS['osC_Payment_' . $module]->isEnabled()) {
244314             $active++;
  245315           }
  246316         }
     
 !
259329       return $has_keys;
  260330     }
  261331 
<>  332+    function getPostTransactionActions($history) {
   333+      return false;
   334+    }
   335+
<_ 262336     function install() {
  263337       global $osC_Database, $osC_Language;
  264338