Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hello All,

 

I just finished installing the Credit Class & Gift Vouchers add on (thanks to the contributors). Everything seems to be working (discounts, calculations, etc.) except that when I choose one of these payment processors:

 

Credit or Debit Card (Processed securely by PayPal)

PayPal Express (including Credit Cards and Debit Cards)

 

It does not redirect me to PayPal. It just goes straight to the Finished page. Please help. Thank you in advance.

Posted

I have been researching and it seems that the offending code is within /catalog/includes/classes/payment.php. Below are some snippets of the code. I need help please. Thanks.

 

/catalog/includes/classes/payment.php

<?php
/*
 $Id: payment.php,v 1.37 2003/06/09 22:26:32 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class payment {
   var $modules, $selected_module;

// class constructor
   function payment($module = '') {
     global $payment, $language, $PHP_SELF;

// Start - CREDIT CLASS Gift Voucher Contribution
     if (defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && !$module == 'credit_covers') {
// End - CREDIT CLASS Gift Voucher Contribution
       $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);

       $include_modules = array();

       if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
         $this->selected_module = $module;

         $include_modules[] = array('class' => $module, 'file' => $module . '.php');
       } else {
         reset($this->modules);
         while (list(, $value) = each($this->modules)) {
           $class = substr($value, 0, strrpos($value, '.'));
           $include_modules[] = array('class' => $class, 'file' => $value);
         }
       }

       for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
         include(DIR_WS_LANGUAGES . $language . '/modules/payment/' . $include_modules[$i]['file']);
         include(DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file']);

         $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
       }

// if there is only one payment method, select it as default because in
// checkout_confirmation.php the $payment variable is being assigned the
// $HTTP_POST_VARS['payment'] value which will be empty (no radio button selection possible)
       if ( (tep_count_payment_modules() == 1) && (!isset($GLOBALS[$payment]) || (isset($GLOBALS[$payment]) && !is_object($GLOBALS[$payment]))) ) {
         $payment = $include_modules[0]['class'];
       }

       if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) {
         $this->form_action_url = $GLOBALS[$module]->form_action_url;
       }
     }
   }

// class methods
/* 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.
*/   
   function update_status() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module])) {
         if (function_exists('method_exists')) {
           if (method_exists($GLOBALS[$this->selected_module], 'update_status')) {
             $GLOBALS[$this->selected_module]->update_status();
           }
         } else { // PHP3 compatibility
           @call_user_method('update_status', $GLOBALS[$this->selected_module]);
         }
       }
     }
   }

// Start - CREDIT CLASS Gift Voucher Contribution
// function javascript_validation() {
 function javascript_validation($coversAll) {
//added the $coversAll to be able to pass whether or not the voucher will cover the whole
//price or not.  If it does, then let checkout proceed when just it is passed.
     $js = '';
     if (is_array($this->modules)) {
       if ($coversAll) {
         $addThis='if (document.checkout_payment.cot_gv.checked) {
           payment_value=\'cot_gv\';
         } else ';
       } else {
         $addThis='';
       }
// End - CREDIT CLASS Gift Voucher Contribution
       $js = '<script language="javascript"><!-- ' . "\n" .
             'function check_form() {' . "\n" .
             '  var error = 0;' . "\n" .
             '  var error_message = "' . JS_ERROR . '";' . "\n" .
// Start - CREDIT CLASS Gift Voucher Contribution
             '  var payment_value = null;' . "\n" .$addThis . 
// End - CREDIT CLASS Gift Voucher Contribution
             '  if (document.checkout_payment.payment.length) {' . "\n" .
             '    for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" .
             '      if (document.checkout_payment.payment[i].checked) {' . "\n" .
             '        payment_value = document.checkout_payment.payment[i].value;' . "\n" .
             '      }' . "\n" .
             '    }' . "\n" .
             '  } else if (document.checkout_payment.payment.checked) {' . "\n" .
             '    payment_value = document.checkout_payment.payment.value;' . "\n" .
             '  } else if (document.checkout_payment.payment.value) {' . "\n" .
             '    payment_value = document.checkout_payment.payment.value;' . "\n" .
             '  }' . "\n\n";

       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $js .= $GLOBALS[$class]->javascript_validation();
         }
       }

// Start - CREDIT CLASS Gift Voucher Contribution
//        $js .= "\n" . '  if (payment_value == null) {' . "\n" .
       $js .= "\n" . '  if (payment_value == null && submitter != 1) {' . "\n" . // CCGV Contribution
              '    error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" .
              '    error = 1;' . "\n" .
              '  }' . "\n\n" .
//               '  if (error == 1) {' . "\n" .
              '  if (error == 1 && submitter != 1) {' . "\n" .
// End - CREDIT CLASS Gift Voucher Contribution
              '    alert(error_message);' . "\n" .
              '    return false;' . "\n" .
              '  } else {' . "\n" .
              '    return true;' . "\n" .
              '  }' . "\n" .
              '}' . "\n" .
              '//--></script>' . "\n";
     }

     return $js;
   }

   function checkout_initialization_method() {
     $initialize_array = array();

     if (is_array($this->modules)) {
       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) {
           $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method();
         }
       }
     }

     return $initialize_array;
   }

   function selection() {
     $selection_array = array();

     if (is_array($this->modules)) {
       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $selection = $GLOBALS[$class]->selection();
           if (is_array($selection)) $selection_array[] = $selection;
         }
       }
     }

     return $selection_array;
   }

// Start - CREDIT CLASS Gift Voucher Contribution
// check credit covers was setup to test whether credit covers is set in other parts of the code
 function check_credit_covers() {
 	global $credit_covers;

 	return $credit_covers;
 }
// End - CREDIT CLASS Gift Voucher Contribution

   function pre_confirmation_check() {
// Start - CREDIT CLASS Gift Voucher Contribution
     global $credit_covers, $payment_modules; 
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         if ($credit_covers) {
           $GLOBALS[$this->selected_module]->enabled = false;
           $GLOBALS[$this->selected_module] = NULL;
           $payment_modules = '';
         } else {
           $GLOBALS[$this->selected_module]->pre_confirmation_check();
         }
// End - CREDIT CLASS Gift Voucher Contribution
       }
     }
   }

   function confirmation() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->confirmation();
       }
     }
   }

   function process_button() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->process_button();
       }
     }
   }

   function before_process() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->before_process();
       }
     }
   }

   function after_process() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->after_process();
       }
     }
   }

   function get_error() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->get_error();
       }
     }
   }
 }
?>

Posted

bump

 

I have been researching and it seems that the offending code is within /catalog/includes/classes/payment.php. Below are some snippets of the code. I need help please. Thanks.

 

/catalog/includes/classes/payment.php

<?php
/*
 $Id: payment.php,v 1.37 2003/06/09 22:26:32 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class payment {
   var $modules, $selected_module;

// class constructor
   function payment($module = '') {
     global $payment, $language, $PHP_SELF;

// Start - CREDIT CLASS Gift Voucher Contribution
     if (defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && !$module == 'credit_covers') {
// End - CREDIT CLASS Gift Voucher Contribution
       $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);

       $include_modules = array();

       if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
         $this->selected_module = $module;

         $include_modules[] = array('class' => $module, 'file' => $module . '.php');
       } else {
         reset($this->modules);
         while (list(, $value) = each($this->modules)) {
           $class = substr($value, 0, strrpos($value, '.'));
           $include_modules[] = array('class' => $class, 'file' => $value);
         }
       }

       for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
         include(DIR_WS_LANGUAGES . $language . '/modules/payment/' . $include_modules[$i]['file']);
         include(DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file']);

         $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
       }

// if there is only one payment method, select it as default because in
// checkout_confirmation.php the $payment variable is being assigned the
// $HTTP_POST_VARS['payment'] value which will be empty (no radio button selection possible)
       if ( (tep_count_payment_modules() == 1) && (!isset($GLOBALS[$payment]) || (isset($GLOBALS[$payment]) && !is_object($GLOBALS[$payment]))) ) {
         $payment = $include_modules[0]['class'];
       }

       if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) {
         $this->form_action_url = $GLOBALS[$module]->form_action_url;
       }
     }
   }

// class methods
/* 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.
*/   
   function update_status() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module])) {
         if (function_exists('method_exists')) {
           if (method_exists($GLOBALS[$this->selected_module], 'update_status')) {
             $GLOBALS[$this->selected_module]->update_status();
           }
         } else { // PHP3 compatibility
           @call_user_method('update_status', $GLOBALS[$this->selected_module]);
         }
       }
     }
   }

// Start - CREDIT CLASS Gift Voucher Contribution
// function javascript_validation() {
 function javascript_validation($coversAll) {
//added the $coversAll to be able to pass whether or not the voucher will cover the whole
//price or not.  If it does, then let checkout proceed when just it is passed.
     $js = '';
     if (is_array($this->modules)) {
       if ($coversAll) {
         $addThis='if (document.checkout_payment.cot_gv.checked) {
           payment_value=\'cot_gv\';
         } else ';
       } else {
         $addThis='';
       }
// End - CREDIT CLASS Gift Voucher Contribution
       $js = '<script language="javascript"><!-- ' . "\n" .
             'function check_form() {' . "\n" .
             '  var error = 0;' . "\n" .
             '  var error_message = "' . JS_ERROR . '";' . "\n" .
// Start - CREDIT CLASS Gift Voucher Contribution
             '  var payment_value = null;' . "\n" .$addThis . 
// End - CREDIT CLASS Gift Voucher Contribution
             '  if (document.checkout_payment.payment.length) {' . "\n" .
             '    for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" .
             '      if (document.checkout_payment.payment[i].checked) {' . "\n" .
             '        payment_value = document.checkout_payment.payment[i].value;' . "\n" .
             '      }' . "\n" .
             '    }' . "\n" .
             '  } else if (document.checkout_payment.payment.checked) {' . "\n" .
             '    payment_value = document.checkout_payment.payment.value;' . "\n" .
             '  } else if (document.checkout_payment.payment.value) {' . "\n" .
             '    payment_value = document.checkout_payment.payment.value;' . "\n" .
             '  }' . "\n\n";

       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $js .= $GLOBALS[$class]->javascript_validation();
         }
       }

// Start - CREDIT CLASS Gift Voucher Contribution
//        $js .= "\n" . '  if (payment_value == null) {' . "\n" .
       $js .= "\n" . '  if (payment_value == null && submitter != 1) {' . "\n" . // CCGV Contribution
              '    error_message = error_message + "' . JS_ERROR_NO_PAYMENT_MODULE_SELECTED . '";' . "\n" .
              '    error = 1;' . "\n" .
              '  }' . "\n\n" .
//               '  if (error == 1) {' . "\n" .
              '  if (error == 1 && submitter != 1) {' . "\n" .
// End - CREDIT CLASS Gift Voucher Contribution
              '    alert(error_message);' . "\n" .
              '    return false;' . "\n" .
              '  } else {' . "\n" .
              '    return true;' . "\n" .
              '  }' . "\n" .
              '}' . "\n" .
              '//--></script>' . "\n";
     }

     return $js;
   }

   function checkout_initialization_method() {
     $initialize_array = array();

     if (is_array($this->modules)) {
       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) {
           $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method();
         }
       }
     }

     return $initialize_array;
   }

   function selection() {
     $selection_array = array();

     if (is_array($this->modules)) {
       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $selection = $GLOBALS[$class]->selection();
           if (is_array($selection)) $selection_array[] = $selection;
         }
       }
     }

     return $selection_array;
   }

// Start - CREDIT CLASS Gift Voucher Contribution
// check credit covers was setup to test whether credit covers is set in other parts of the code
 function check_credit_covers() {
 	global $credit_covers;

 	return $credit_covers;
 }
// End - CREDIT CLASS Gift Voucher Contribution

   function pre_confirmation_check() {
// Start - CREDIT CLASS Gift Voucher Contribution
     global $credit_covers, $payment_modules; 
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         if ($credit_covers) {
           $GLOBALS[$this->selected_module]->enabled = false;
           $GLOBALS[$this->selected_module] = NULL;
           $payment_modules = '';
         } else {
           $GLOBALS[$this->selected_module]->pre_confirmation_check();
         }
// End - CREDIT CLASS Gift Voucher Contribution
       }
     }
   }

   function confirmation() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->confirmation();
       }
     }
   }

   function process_button() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->process_button();
       }
     }
   }

   function before_process() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->before_process();
       }
     }
   }

   function after_process() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->after_process();
       }
     }
   }

   function get_error() {
     if (is_array($this->modules)) {
       if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
         return $GLOBALS[$this->selected_module]->get_error();
       }
     }
   }
 }
?>

Posted (edited)

Try using this:

 

// Start - CREDIT CLASS Gift Voucher Contribution
     if (defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && $module != 'credit_covers') {
// End - CREDIT CLASS Gift Voucher Contribution

 

It's the only line I found different from my own CCGV install.

Edited by a.forever

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...