Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Passing cartID to paymet gateway


DAVID3733

Recommended Posts

Hi There

 

I have a long standing modified version of RCA2

 

I have installed IOSC which is a mobile version of the site but i am having a problem passing the CartID to worlpay gateway, then if i click back on the browser it goes through fine

 

I have studied the header info and the only thing is missing is the cart if ,ie

 

Not working

POST /wcc/purchase instId=999999&amount=134.95&currency=GBP&hideCurrency=true&cartId= &desc=websitename&name, bla bla bla

 

working

POST /wcc/purchase instId=999999&amount=134.95&currency=GBP&hideCurrency=true&cartId=89898989 &desc=websitename&name, bla bla bla

 

so the only difference is that it is not sending the cart ID

 

Its not sending me to shipping page so at the start of the page it must have the cartID and of course when its refeshed it is there

 

I assume sothing is knocking it out in the page somewhere, is there an easy way to reinstate it in the form section of the page? before its posted?

 

I have tried messing about with placing

<?php $cartID=$cartID ?>

 

but that has not helped, and i have read many many posts but nobody has the same issue, its probably because my setup is not stock, maybe its in the classes that the problem is occuring, any pointers would be gratefully recieved.

 

David

David

Link to comment
Share on other sites

Just an update ,

 

it appears that the worldpay class is supplying all the data required

 

  $process_button_string = tep_draw_hidden_field('instId', MODULE_PAYMENT_WORLDPAY_JUNIOR_INSTALLATION_ID) .
						   tep_draw_hidden_field('amount', $this->format_raw($order->info['total'])) .
						   tep_draw_hidden_field('currency', $currency) .
						   tep_draw_hidden_field('hideCurrency', 'true') .
						   tep_draw_hidden_field('cartId', $order_id) .
						   tep_draw_hidden_field('desc', STORE_NAME) .
						   tep_draw_hidden_field('name', $order->billing['firstname'] . ' ' . $order->billing['lastname']) .
						   tep_draw_hidden_field('address', $order->billing['street_address']) .
						   tep_draw_hidden_field('postcode', $order->billing['postcode']) .
						   tep_draw_hidden_field('country', $order->billing['country']['iso_code_2']) .
						   tep_draw_hidden_field('tel', $order->customer['telephone']) .
						   tep_draw_hidden_field('email', $order->customer['email_address']) .
 //							 tep_draw_hidden_field('fixContact', 'Y') .
						   tep_draw_hidden_field('lang', strtoupper($lang['code'])) .
						   tep_draw_hidden_field('signatureFields', 'amount:currency:cartId') .
						   tep_draw_hidden_field('signature', md5(MODULE_PAYMENT_WORLDPAY_JUNIOR_MD5_PASSWORD . ':' . $this->format_raw($order->info['total']) . ':' . $currency . ':' . $order_id)) .
						   tep_draw_hidden_field('MC_callback', substr(tep_href_link('ext/modules/payment/worldpay/junior_callback.php', '', 'NONSSL', false, false), strpos(tep_href_link('ext/modules/payment/worldpay/junior_callback.php', '', 'NONSSL', false, false), '://')+3));

 

but the order id is coming up blank when it is brought into the checkout_confirmation page (all the other information is there, amount clients name etc), and if you refresh the page after its loaded the missing order id is there.

 

I have been looking at this for days now so any clues would be very much appriciated.

David

Link to comment
Share on other sites

The $process_button which appears to contain all the data i need on checkout_confirmation.php looks like is called from the worldpay_junior.php file by the /includes/classes/payment.php

 

This in turn is called by the checkout_confirmation.php page, now all the data i need is there except the order_id, but if i refresh the page that is also there.

 

I have been trying to find where the order id is reset, this appears to be done the worlpay_junior.php file (cart_worldpay_id)

 

// load the after_process function from the payment modules
  $this->after_process();
  $cart->reset(true);
// unregister session variables used during checkout
  tep_session_unregister('sendto');
  tep_session_unregister('billto');
  tep_session_unregister('shipping');
  tep_session_unregister('payment');
  tep_session_unregister('comments');
  tep_session_unregister('cart_Worldpay_Junior_ID');
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 

which is after the $this->after_process(); which i think is right

 

so the pages that are called, ie includes/classes/payment.php and includes/modules/payment/worldpayjunior.php are also called by the main site which works fine (the bit i am working on is a mobile phone front for mymain site), so i can only assume that something in includes/calsses/payment.php is calling something that is not common and knocking out the order id, i have included that page below just to see if anyone might be able to spot the problem in it

 

<?php
/*
 $Id: payment.php 1739 2007-12-20 00:52:16Z hpdl $
 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)) {
 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();
    }
  }
   }
 }
?>

 

One other thing that might give a clue, the cart is not always emptied after a sale, not sure if that might give any pointers to anyone, this is unfortunatly beyond my skills (limited as they are) and really would appriciate any assistance available,

 

Thank you

 

 

David

David

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...