payment Class Reference

Inherits AbstractAcaModule.

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Static Protected Attributes


Detailed Description

Definition at line 17 of file payment.php.


Constructor & Destructor Documentation

payment::__construct ( module = ''  ) 

Definition at line 23 of file payment.php.

00023                                    {
00024     self::initialise($module);
00025   }


Member Function Documentation

payment::after_process (  ) 

catalog/checkout_process.php

Definition at line 225 of file payment.php.

00225                                   {
00226     if (is_array($this->modules)) {
00227       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)&& method_exists($GLOBALS[$this->selected_module], 'after_process')  ) {
00228         return $GLOBALS[$this->selected_module]->after_process();
00229       }
00230     }
00231   }

payment::before_process (  ) 

catalog/checkout_process.php

Definition at line 214 of file payment.php.

00214                             {
00215     if (is_array($this->modules)) {
00216       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)&& method_exists($GLOBALS[$this->selected_module], 'before_process')  ) {
00217         return $GLOBALS[$this->selected_module]->before_process();
00218       }
00219     }
00220   }

payment::confirmation (  ) 

catalog/checkout_confirmation.php

Definition at line 192 of file payment.php.

00192                                  {
00193     if (is_array($this->modules)) {
00194       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) && method_exists($GLOBALS[$this->selected_module], 'confirmation') ) {
00195         return $GLOBALS[$this->selected_module]->confirmation();
00196       }
00197     }
00198   }

payment::get_error (  ) 

Definition at line 244 of file payment.php.

00244                               {
00245     if (is_array($this->modules)) {
00246       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)&& method_exists($GLOBALS[$this->selected_module], 'pre_confirmation_check')  ) {
00247         return $GLOBALS[$this->selected_module]->get_error();
00248       }
00249     }
00250   }

static payment::getInstance ( module = ''  )  [static]

Definition at line 27 of file payment.php.

00028   {
00029       if(self::$_instance == null) {
00030           self::$_instance = new self($module);
00031       }
00032       return self::$_instance;
00033   }

payment::initialise ( module = ''  ) 

class constructor

Parameters:
$module string

Definition at line 46 of file payment.php.

Referenced by __construct().

00046                                            {
00047     global $payment, $language, $PHP_SELF,$customer_id,$page,$lang;
00048 
00049     $include_modules = array();
00050     if  (tep_not_null($module))  {
00051       $this->selected_module = $module;
00052       foreach(parent::initialise_type('MODULE_PAYMENT_INSTALLED','payment') as $class){
00053         if($class == $module) $include_modules[] = array('class' => $class, 'file' => $class . '.php');
00054       }
00055     } else {
00056       foreach(parent::initialise_type('MODULE_PAYMENT_INSTALLED','payment') as $class){
00057         $include_modules[] = array('class' => $class, 'file' => $class . '.php');
00058       }
00059     }
00060 
00061     if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') $customer_group_id = $_SESSION['sppc_customer_group_id'];
00062     else  $customer_group_id = '0';
00063 
00064     $customer_payment_query = tep_db_query("select IF(c.customers_payment_allowed <> '', c.customers_payment_allowed, cg.group_payment_allowed) as payment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id =  '" . $customer_group_id . "'");
00065     $customer_ot = tep_db_fetch_array($customer_payment_query);
00066     $temp_payment_array= (tep_not_null($customer_ot['payment_allowed']) )  ? explode(';', $customer_ot['payment_allowed']) : array() ;
00067 
00068     foreach($include_modules as $imod){
00069       if( ( count($temp_payment_array)==0 || in_array($imod['file'], $temp_payment_array ) ) ){
00070         if(!class_exists($imod['class'])) break;
00071         $GLOBALS[$imod['class']] = new $imod['class'];
00072         $this->modules[]=$imod['class'];
00073       }
00074     }
00075 
00076     // if there is only one payment method, select it as default because in
00077     // checkout_confirmation.php the $payment variable is being assigned the
00078     // $_POST['payment'] value which will be empty (no radio button selection possible)
00079     if ( (tep_count_payment_modules() == 1) && (!isset($GLOBALS[$payment]) || (isset($GLOBALS[$payment]) && !is_object($GLOBALS[$payment]))) ) {
00080         /*$this->selected_module=*/$payment = $include_modules[0]['class'];
00081     }
00082 
00083     if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) {
00084       $this->form_action_url = $GLOBALS[$module]->form_action_url;
00085     }
00086 
00087   }

payment::javascript_validation (  ) 

push js in class javascript

Definition at line 110 of file payment.php.

00110                                           {
00111     global $page;
00112     $js = '';
00113     if (is_array($this->modules)) {
00114       $js = '<script type="text/javascript"><!-- ' . "\n" .
00115             'function check_form() {' . "\n" .
00116             '  var error = 0;' . "\n" .
00117             '  var error_message = "' . JS_ERROR . '";' . "\n" .
00118             '  var payment_value = null;' . "\n" .
00119             '  if (document.getElementById("checkout_payment").payment.length) {' . "\n" .
00120             '    for (var i=0; i<document.getElementById("checkout_payment").payment.length; i++) {' . "\n" .
00121             '      if (document.getElementById("checkout_payment").payment[i].checked) {' . "\n" .
00122             '        payment_value = document.getElementById("checkout_payment").payment[i].value;' . "\n" .
00123             '      }' . "\n" .
00124             '    }' . "\n" .
00125             '  } else if (document.getElementById("checkout_payment").payment.checked) {' . "\n" .
00126             '    payment_value = document.getElementById("checkout_payment").payment.value;' . "\n" .
00127             '  } else if (document.getElementById("checkout_payment").payment.value) {' . "\n" .
00128             '    payment_value = document.getElementById("checkout_payment").payment.value;' . "\n" .
00129             '  }' . "\n\n";
00130 
00131       reset($this->modules);
00132       foreach($this->modules as $class){
00133         if (isset($GLOBALS[$class]) &&$GLOBALS[$class]->enabled)  $js .= $GLOBALS[$class]->javascript_validation();
00134       }
00135 
00136       $js .= "\n" .'if (document.getElementById("conditions").checked != true) {' . "\n" .
00137             '    error_message = error_message + "' . JS_ERROR_NO_CHECK_CONDITION . '\n";' . "\n" .
00138             '    error = 1;' . "\n" .
00139             '  }' . "\n";
00140 
00141       $js .= "\n" . 'if (payment_value == null) {' . "\n" .
00142             '    error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" .
00143             '    error = 1;' . "\n" .
00144             '  }' . "\n\n" .
00145             '  if (error == 1) {' . "\n" .
00146             '    alert(error_message);' . "\n" .
00147             '    return false;' . "\n" .
00148             '  } else {' . "\n" .
00149             '    return true;' . "\n" .
00150             '  }' . "\n" .
00151             '}' . "\n" .
00152             '//--></script>' . "\n";
00153     }
00155 //     $page->javascript->add_script_src(array('file'=>'payment_javascript_validation','script'=>tep_output_string_protected($js,false,true)) );
00156     return $js;
00157   }

payment::payment_succes (  ) 

catalog/checkout_success.php

Definition at line 236 of file payment.php.

00236                             {
00237     if (is_array($this->modules)) {
00238       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)&& method_exists($GLOBALS[$this->selected_module], 'payment_succes')  ) {
00239         return $GLOBALS[$this->selected_module]->payment_succes();
00240       }
00241     }
00242   }

payment::pre_confirmation_check (  ) 

catalog/checkout_payment.php

Definition at line 180 of file payment.php.

00180                                            {
00181     if (is_array($this->modules)) {
00182       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) && method_exists($GLOBALS[$this->selected_module], 'pre_confirmation_check') ) {
00183         $GLOBALS[$this->selected_module]->pre_confirmation_check();
00184       }
00185     }
00186 
00187   }

payment::process_button (  ) 

catalog/checkout_confirmation.php

Definition at line 203 of file payment.php.

00203                                    {
00204     if (is_array($this->modules)) {
00205       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)&& method_exists($GLOBALS[$this->selected_module], 'process_button')  ) {
00206         return $GLOBALS[$this->selected_module]->process_button();
00207       }
00208     }
00209   }

static payment::resetInstance (  )  [static]

Definition at line 35 of file payment.php.

00036   {
00037       self::$_instance = null;
00038       return self::getInstance();
00039   }

payment::selection (  ) 

catalog/checkout_payment.php

Definition at line 162 of file payment.php.

00162                               {
00163     $selection_array = array();
00164 
00165     if (is_array($this->modules)) {
00166       reset($this->modules);
00167       foreach($this->modules as $class){
00168         if (isset($GLOBALS[$class]) && $GLOBALS[$class]->enabled) {
00169           $selection = $GLOBALS[$class]->selection();
00170           if (is_array($selection)) $selection_array[] = $selection;
00171         }
00172       }
00173     }
00174     return $selection_array;
00175   }

payment::update_status (  ) 

catalog/checkout_confirmation.php

The following method is needed in the checkout_confirmation.php page due to a chicken and egg problem with the payment class and order class. The payment modules needs the order destination data for the dynamic status feature, and the order class needs the payment module title. The following method is a work-around to implementing the method in all payment modules available which would break the modules in the contributions section. This should be looked into again post 2.2.

Definition at line 100 of file payment.php.

00100                                   {
00101     if (is_array($this->modules)) {
00102       if (is_object($GLOBALS[$this->selected_module])) {
00103         if (method_exists($GLOBALS[$this->selected_module], 'update_status')) {
00104         $GLOBALS[$this->selected_module]->update_status();
00105         }
00106       }
00107     }
00108   }


Member Data Documentation

payment::$_instance [static, protected]

Reimplemented from page.

Definition at line 21 of file payment.php.

payment::$modules = array()

Definition at line 18 of file payment.php.

payment::$selected_module

Definition at line 19 of file payment.php.


The documentation for this class was generated from the following file: