Jump to content
Sign in to follow this  
kgspottery

No "thank you" page, product still in shopping cart

Recommended Posts

Hello all -

 

My client required that we use NobelPay aka Tranvia to process his credit cards. I got the install from the company, which included two .php files uploaded to the server, that's it.

 

Everything seems to be working just great: Credit cards go right through, are charged.

 

Two problems:

 

1. After the final "continue" button is pushed, the credit card is charged behind the scenes and the user is directed immediately back to the Login page. No "thank you for your order, print this page for your records" etc. Nothing. You can't even tell a transaction happened.

 

2. After this invisible transaction, the "shopping cart" box on the right column shows empty. But if you click on the arrow in that box, or on "Cart Contents" you'll see that the item you just purchased is actually still in your shopping cart. Even though, unbeknownst to you, your credit card was just charged for said item.

 

Any thoughts? Any help? Our test site: http://rescuepad.com/catalog/index.php?cPath=2

 

Thanking you all in advance! I also have an e-mail in to the NobelPay folks to see if they can point me in the right direction.

 

I have posted the code for the two files below.

 

 

includes/languages/english/modules/payment/nobelpay.php

 

<?php
/*
 $Id: nobelpay.php,v 1.00 2003/03/10 17:04:12 eak Exp $

 The Exchange Project - Community Made Shopping!
 http://www.theexchangeproject.org

 Copyright (c) 2000,2001 The Exchange Project

 Released under the GNU General Public License
*/

 define('MODULE_PAYMENT_NOBELPAY_TEXT_TITLE', 'Credit Card');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_TEST_TITLE', 'NobelPay<br>TEST MODE</strong>');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_TEST_DESCRIPTION', 'NobelPay<br><strong>Test Module</strong><br>Credit Card Test Info:<br><br>CC#: 4111111111111111<br>Expiry: Any');

 define('MODULE_PAYMENT_NOBELPAY_TEXT_DESCRIPTION', 'Process payments via NobelPay <br><b>>> <a href="http://www.nobelpay.com" target="_blank"><u>More Info</u></a></b>');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_TYPE', 'Type:');

 define('MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_OWNER', 'Name on Credit Card:');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_CARD_INFO', 'Credit Card Information:');

 define('MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_NUMBER', 'Credit Card Number:');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_EXPIRES', 'Expiration Date:');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_CVV2_NUMBER', 'Verification Number (last 3-4 digits on back of card):');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_JS_CC_NUMBER', '* The credit card number must be at least ' . CC_NUMBER_MIN_LENGTH . ' characters.\n');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_JS_CC_CVV', '* You must enter the 3 or 4 digit number on the back of your credit card\n');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_ERROR_MESSAGE', 'There has been an error processing your credit card, please try again.');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_ERROR_DECLINE', 'We are sorry, but your credit card has been declined by our system.');
 define('MODULE_PAYMENT_NOBELPAY_TEXT_ERROR', 'We are sorry, there was an error.  Please check your card details.');
?>

 

 

 

includes/modules/payment/nobelpay.php

 

<?php
/*
 $Id: nobelpay.php,v 1.0 2003/03/10 22:03:00 eak Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class nobelpay {
var $code, $title, $description, $enabled;

////////////////////////////////////////////////////
// Class constructor -> initialize class variables.
// Sets the class code, description, and status.
////////////////////////////////////////////////////


function nobelpay() {
  global $order;

  $this->code = 'nobelpay';
if (MODULE_PAYMENT_NOBELPAY_TESTMODE == 'True') {
  $this->title = MODULE_PAYMENT_NOBELPAY_TEXT_TEST_TITLE;
  $this->description = MODULE_PAYMENT_NOBELPAY_TEXT_TEST_DESCRIPTION;
  } else {
  $this->title = MODULE_PAYMENT_NOBELPAY_TEXT_TITLE;
  $this->description = MODULE_PAYMENT_NOBELPAY_TEXT_DESCRIPTION;
}
  $this->enabled = ((MODULE_PAYMENT_NOBELPAY_STATUS == 'True') ? true : false);
  $this->sort_order = MODULE_PAYMENT_NOBELPAY_SORT_ORDER;

  if ((int)MODULE_PAYMENT_NOBELPAY_ORDER_STATUS_ID > 0) {
	$this->order_status = MODULE_PAYMENT_NOBELPAY_ORDER_STATUS_ID;
  }

  if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_NOBELPAY_ZONE > 0) ) {
	$check_flag = false;
	$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_NOBELPAY_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
	while ($check = tep_db_fetch_array($check_query)) {
	  if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
	  } elseif ($check['zone_id'] == $order->billing['zone_id']) {
		$check_flag = true;
		break;
	  }
	}

	if ($check_flag == false) {
	  $this->enabled = false;
	}
  }

// disable the module if the order only contains virtual products
// If you wish you can remove the commented lines below

//	  if ($this->enabled == true) {
//	   if ($order->content_type == 'virtual') {
//	   $this->enabled = false;
//	 }
// }


// Which Form Action are we going to use?
// If we are in 'Testmode' we use the 'Test Server'

if (MODULE_PAYMENT_NOBELPAY_TESTMODE == 'TRUE') {
			$this->form_action_url = "https://www.nobelpay.com/test/nobelpaytest.asp";
	} else {
			$this->form_action_url = "https://www.nobelpay.com/prod/nobelpay.asp";
			}
}


////////////////////////////////////////////////////
// Javascript form validation
// Check the user input submited on checkout_payment.php with javascript (client-side).
// Examples: validate credit card number, make sure required fields are filled in
////////////////////////////////////////////////////

function javascript_validation() {
  $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
		'	var cc_owner = document.checkout_payment.nobelpay_cc_owner.value;' . "\n" .
		'	var cc_number = document.checkout_payment.nobelpay_cc_number.value;' . "\n" .
					'		 var cc_cvv = document.checkout_payment.nobelpay_cc_cvv.value;' . "\n" .
		'	if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
		'	  error_message = error_message + "' . MODULE_PAYMENT_NOBELPAY_TEXT_JS_CC_OWNER . '";' . "\n" .
		'	  error = 1;' . "\n" .
		'	}' . "\n" .
		'	if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
		'	  error_message = error_message + "' . MODULE_PAYMENT_NOBELPAY_TEXT_JS_CC_NUMBER . '";' . "\n" .
		'	  error = 1;' . "\n" .
		'	}' . "\n" .
					'		 if (cc_cvv == "" || cc_cvv.length < "3") {' . "\n".
					'		   error_message = error_message + "' . MODULE_PAYMENT_NOBELPAY_TEXT_JS_CC_CVV . '";' . "\n" .
					'		   error = 1;' . "\n" .
					'		 }' . "\n" .
		'  }' . "\n";

  return $js;
}


////////////////////////////////////////////////////
// !Form fields for user input
// Output any required information in form fields
// Examples: ask for extra fields (credit card number), display extra information
////////////////////////////////////////////////////


function selection() {
  global $order;

  for ($i=1; $i<13; $i++) {
	$expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
  }

  $today = getdate();
  for ($i=$today['year']; $i < $today['year']+10; $i++) {
	$expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));
  }
  $selection = array('id' => $this->code,
					 'module' => $this->title,
					 'fields' => array(array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_OWNER,
											 'field' => tep_draw_input_field('nobelpay_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
									   array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_NUMBER,
											 'field' => tep_draw_input_field('nobelpay_cc_number')),
									   array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_EXPIRES,
											 'field' => tep_draw_pull_down_menu('nobelpay_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('nobelpay_cc_expires_year', $expires_year)),
						   array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CVV2_NUMBER . ' ' .' ',
											 'field' => tep_draw_input_field('nobelpay_cc_cvv','','SIZE=4, MAXLENGTH=4'))));

  return $selection;
}


////////////////////////////////////////////////////
// Pre confirmation checks (ie, check if credit card
// information is right before sending the info to
// the payment server
////////////////////////////////////////////////////

function pre_confirmation_check() {
  global $HTTP_POST_VARS, $nobelpay_cc_cvv;

  include(DIR_WS_CLASSES . 'cc_validation.php');


  $cc_validation = new cc_validation();
  $result = $cc_validation->validate($HTTP_POST_VARS['nobelpay_cc_number'], $HTTP_POST_VARS['nobelpay_cc_expires_month'], $HTTP_POST_VARS['nobelpay_cc_expires_year'],  $HTTP_POST_VARS['nobelpay_cc_cvv']);
  $error = '';
  switch ($result) {
	case -1:
	  $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4));
	  break;
	case -2:
	case -3:
	case -4:
	  $error = TEXT_CCVAL_ERROR_INVALID_DATE;
	  break;
	case false:
	  $error = TEXT_CCVAL_ERROR_INVALID_NUMBER;
	  break;
  }

  if ( ($result == false) || ($result < 1) ) {
	$payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&nobelpay_cc_owner=' . urlencode($HTTP_POST_VARS['nobelpay_cc_owner']) . '&nobelpay_cc_expires_month=' . $HTTP_POST_VARS['nobelpay_cc_expires_month'] . '&nobelpay_cc_expires_year=' . $HTTP_POST_VARS['nobelpay_cc_expires_year'] . '&nobelpay_cc_cvv=' . $HTTP_POST_VARS['nobelpay_cc_cvv'];

	tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));
  }

  $this->cc_card_type = $cc_validation->cc_type;
  $this->cc_card_number = $cc_validation->cc_number;
  $this->cc_expiry_month = $cc_validation->cc_expiry_month;
  $this->cc_expiry_year = $cc_validation->cc_expiry_year;

}


////////////////////////////////////////////////////
// Functions to execute before displaying the checkout
// confirmation page
////////////////////////////////////////////////////

function confirmation() {
  global $HTTP_POST_VARS;


  $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
						'fields' => array(array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_OWNER,
												'field' => $HTTP_POST_VARS['nobelpay_cc_owner']),
										  array('title' => 'CVV number',
												'field' => $HTTP_POST_VARS['nobelpay_cc_cvv']),
										  array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_NUMBER,
												'field' => substr($this->cc_card_number, 0, 4) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)),
										  array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_CREDIT_CARD_EXPIRES,
												'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['nobelpay_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['nobelpay_cc_expires_year'])))));


  return $confirmation;
}

////////////////////////////////////////////////////
// Functions to execute before finishing the form
// Examples: add extra hidden fields to the form
////////////////////////////////////////////////////

function process_button() {
  global $HTTP_POST_VARS, $order, $customer_id;

  $uid = tep_create_random_value(16, 'digits'); // Create a UID for the order

  $process_button_string = tep_draw_hidden_field('MERCHANT', MODULE_PAYMENT_NOBELPAY_LOGIN) .
						   tep_draw_hidden_field('TRANSACTION_TYPE', MODULE_PAYMENT_NOBELPAY_TRANSACTION_TYPE) .
						   tep_draw_hidden_field('CC_NUM', $this->cc_card_number) .
						   tep_draw_hidden_field('CVCCVV2', $HTTP_POST_VARS['nobelpay_cc_cvv']) .
						   tep_draw_hidden_field('CC_EXPIRES', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .
						   tep_draw_hidden_field('AMOUNT', number_format($order->info['total'], 2)) .
						   tep_draw_hidden_field('Order_ID', $uid) .
						   tep_draw_hidden_field('APPROVED_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) .
						   tep_draw_hidden_field('MISSING_URL', tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NOBELPAY_TEXT_ERROR), 'SSL', true, false)) .
						   tep_draw_hidden_field('DECLINED_URL', tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NOBELPAY_TEXT_ERROR_DECLINE), 'SSL', true, false)) .
						   tep_draw_hidden_field('NAME', $order->customer['lastname']) .
						   tep_draw_hidden_field('Addr1', $order->customer['street_address']) .
						   tep_draw_hidden_field('Addr2', $order->customer['']) .// This is a required field
						   tep_draw_hidden_field('CITY', $order->customer['city']) .
						   tep_draw_hidden_field('STATE', $order->customer['state']) .
						   tep_draw_hidden_field('ZIPCODE', $order->customer['postcode']);

//	  if (sID) $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());


  return $process_button_string;
}

////////////////////////////////////////////////////
// Test Credit Card# 5454379001303641
// Expiration any date after current date.
// Functions to execute before processing the order
// Examples: retreive result from online payment services
////////////////////////////////////////////////////


function before_process() {
  global $HTTP_POST_VARS, $customer_id, $order, $vcc;	

  if ($HTTP_POST_VARS['APPROVED_URL'] == 'DECLINED') {  
	tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NOBELPAY_TEXT_ERROR_DECLINE), 'SSL', true, false));

  }
  else if ($HTTP_POST_VARS['APPROVED_URL'] == 'MISSING') {
	tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NOBELPAY_TEXT_ERROR), 'SSL', true, false));
  }


 }


function after_process() {
  return false;
}

////////////////////////////////////////////////////
// If an error occurs with the process, output error messages here
////////////////////////////////////////////////////

function get_error() {
  global $HTTP_GET_VARS;

  $error = array('title' => MODULE_PAYMENT_NOBELPAY_TEXT_ERROR,
				 'error' => stripslashes(urldecode($HTTP_GET_VARS['error'])));

  return $error;
}

////////////////////////////////////////////////////
// Check if module is installed (Administration Tool)
// TABLES: configuration
////////////////////////////////////////////////////


function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_NOBELPAY_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

////////////////////////////////////////////////////
// Install the module (Administration Tool)
// TABLES: configuration
////////////////////////////////////////////////////

function install() {
  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 Nobelpay Module?', 'MODULE_PAYMENT_NOBELPAY_STATUS', 'True', 'Do you want to accept Nobelpay payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now());");
  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_NOBELPAY_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())");
  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_NOBELPAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '3', now())");
  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_NOBELPAY_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '4', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  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 Nobelpay Testing?', 'MODULE_PAYMENT_NOBELPAY_TESTMODE', 'TRUE', 'Do you want to Test?', '6', '5', 'tep_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now());");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Nobelpay ID', 'MODULE_PAYMENT_NOBELPAY_LOGIN', 'NOBELPAYDEMO', 'Your Merchant ID at Nobelpay', '6', '6', now())");
  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_NOBELPAY_TRANSACTION_TYPE', 'AUTH', 'Transaction mode to use for the Nobelpay service', '6', '7', 'tep_cfg_select_option(array(\'SALE\', \'AUTH\'), ', now())");
}

////////////////////////////////////////////////////
// Remove the module (Administration Tool)
// TABLES: configuration
////////////////////////////////////////////////////

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
	 }

////////////////////////////////////////////////////
// Create our Key - > Value Arrays
////////////////////////////////////////////////////

function keys() {
  $keys = array('MODULE_PAYMENT_NOBELPAY_STATUS','MODULE_PAYMENT_NOBELPAY_ZONE','MODULE_PAYMENT_NOBELPAY_SORT_ORDER','MODULE_PAYMENT_NOBELPAY_ORDER_STATUS_ID','MODULE_PAYMENT_NOBELPAY_TESTMODE','MODULE_PAYMENT_NOBELPAY_LOGIN','MODULE_PAYMENT_NOBELPAY_TRANSACTION_TYPE');

  return $keys;
}
}
?>

Share this post


Link to post
Share on other sites

Just thought I'd put the fix on here, in case someone finds this thread via a search.

 

The line

tep_draw_hidden_field('APPROVED_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false))

 

Had to be changed to

 

tep_draw_hidden_field('APPROVED_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true))

 

in the second file. A simple thing - glad I got in touch with the NobelPay guys to tell me what to do!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×