If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Addon Payment Modules / Whoops! Sessions expired but still logged in error after payment (ePDQ - Barclay's)

Whoops! Sessions expired but still logged in error after payment (ePDQ - Barclay's)

Locked

Started by twowayradio on 22 Oct 2010, 10:36 AM · Views: 4,588

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
22 Oct 2010, 10:36 AM
#1
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #1 by twowayradio

Hi all,

Hoping someone can help. Have spent hours searching for a solution and other people have had the same issue but no solution.

We're using Barclays ePDQ module and shared SSL. Checkout works great and payment is taken by Barclays. When the post back to edpq_result.php happens the page forwards to epdq_cpi_handler.php on the SECURE hosting which then immediately directs to (on the non secure webserver)...
index.php?main_page=time_out&zenid=h9hatjc75b4l2emk9p4j2284a4
This page produces the Whoops error page and does not create an order. When I use the test page to emulate a postback to generate the order using the oid={temporderno} the same error occurs, so definitely an issue with ZenCart.

We're using db session caching, epdq module and shared SSL.

Sessions in admin configured as follows...

Session Directory /home/linweb03/d/dksales.co.uk/user/htdocs/cache
Cookie Domain False
Force Cookie Use False
Check SSL Session ID False
Check User Agent False
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true

Has anyone else experienced this or know of a fix? :)

22 Oct 2010, 1:00 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

Does the same thing happen if you use one of the built-in payment modules instead of an addon? ie: check/moneyorder?

And, if you turn off SSL and do another test with your addon, do the same symptoms occur?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Oct 2010, 3:24 PM
#3
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #3 by twowayradio

DrByte:

Does the same thing happen if you use one of the built-in payment modules instead of an addon? ie: check/moneyorder?

And, if you turn off SSL and do another test with your addon, do the same symptoms occur?

Check/money order works fine. Have switched off SSL and it seems to work ok if I change the callback URL's.

22 Oct 2010, 4:16 PM
#4
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #4 by twowayradio

The epdq log table in ZC shows the transaction as a success (with the order no) so Barclays IS posting back, just Zen Cart is not creating the order. However when the customer clicks continue as a success but the redirect from cpi handler gives the whoops page and Zen Cart does not create the order. Does ZC require a session ID to be posted back? Im just wondering aside from the OID GET variable what else ZC needs to run the process_checkout?

22 Oct 2010, 8:23 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #5 by drbyte

Everything it's doing requires that a valid session be present. If the callback system isn't passing the session back properly and the cookie isn't retaining the session properly, it's not going to work.

As you have acknowledged already, Fasthosts does odd unconventional things with their SSL setup, and frequently encounters these kinds of problems when attempting to complete transactions over SSL.

If check/moneyorder works fine then it's not a core Zen Cart issue with checkout.
And, if it works when switching off SSL to isolate causes, then it suggests the addon itself is largely okay, and generally seems to be pointing to an SSL issue ... which suggests a hosting problem.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Oct 2010, 3:03 PM
#6
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #6 by twowayradio

DrByte:

Everything it's doing requires that a valid session be present. If the callback system isn't passing the session back properly and the cookie isn't retaining the session properly, it's not going to work.

As you have acknowledged already, Fasthosts does odd unconventional things with their SSL setup, and frequently encounters these kinds of problems when attempting to complete transactions over SSL.

If check/moneyorder works fine then it's not a core Zen Cart issue with checkout.
And, if it works when switching off SSL to isolate causes, then it suggests the addon itself is largely okay, and generally seems to be pointing to an SSL issue ... which suggests a hosting problem.

When we installed the module we had to use the jump page fix to strip off the ZenID from the URL as Barclays ePDQ did not like dynamic URL's. On the jump page we strip off the zenid GET variable. Because we've stripped it is that whats causing the problem, or is the GET zenid variable not required?

26 Oct 2010, 8:50 AM
#7
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #7 by twowayradio

Dr Byte,
I've found the code that could be causing the error. Since the ePDQ log table is populated then I assume the postback from Barclays is working in epdqresult.php, so the next page is epdq_cpi_handler, which sends the data to checkout process.
In checkout process the following code mentions the timeout page...

// if the customer is not logged on, redirect them to the time out page
  if (!$_SESSION['customer_id']) {
    zen_redirect(zen_href_link(FILENAME_TIME_OUT));
  } else {
    // validate customer
    if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
      $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
  }

// confirm where link came from
if (!strstr($_SERVER['HTTP_REFERER'], FILENAME_CHECKOUT_CONFIRMATION)) {
  //    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,'','SSL'));
}

// BEGIN CC SLAM PREVENTION
if (!isset($_SESSION['payment_attempt'])) $_SESSION['payment_attempt'] = 0;
$_SESSION['payment_attempt']++;
if ($_SESSION['payment_attempt'] > 6) {
  zen_session_destroy();
  zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}
// END CC SLAM PREVENTION

if (!isset($credit_covers)) $credit_covers = FALSE;

// load selected payment module
require(DIR_WS_CLASSES . 'payment.php');
$payment_modules = new payment($_SESSION['payment']);
// load the selected shipping module
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping($_SESSION['shipping']);

require(DIR_WS_CLASSES . 'order.php');
$order = new order;

Now given that when the customer gets the error page they are still logged in, along with their cart contents then I'm guessing it's not because they are logged out. Any ideas what else could be causing it?

26 Oct 2010, 9:06 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #8 by drbyte

That code is checking to see whether the customer's id has been registered in the current session ... which is the primary indicator that the customer is actually logged in. If that fails, then it's redirecting to the timeout page. That code has been copied verbatim from Zen Cart core checkout code. And, while within regular Zen Cart checkout, Zen Cart will assume that if the person has reached this far into checkout and suddenly the customer id is no longer valid, that the customer must have been logged in at one time but the session must have expired or else the customer id wouldn't be missing ... hence the redirect to the timeout page. Your addon is assuming the same premise. Maybe that's an incorrect premise. But, whether it's valid to consider it a "timeout" or not, the fact remains: without a customer id, you're really NOT in that customer's session, so it's certainly appropriate to NOT continue doing any processing without getting back into the correct session again.

And, since the appropriate way to pass the session id back and forth is typically via the URL with a zenid, and you're stripping that off, you're really at a dead end.

If your gateway can't handle passing the required data back and forth, then it's really not ready for prime time.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Oct 2010, 9:34 AM
#9
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #9 by twowayradio

I've created a test page on both the secure and unsecure servers and the session value 'customerid' is always empty (even when logged in), yet ZC doesn't put it in the GET variables until you reach the 'My Account' or checkout pages. Barclays don't have a spare field for me to send the customer_id value and have it posted back, is there a workaround for this? If I create a session (e.g. 'tempcustid') myself using the value of the GET on the checkout page and then re-translate it back from a session value to a get value when I get the postback from Barclays will that work?

26 Oct 2010, 7:50 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #10 by drbyte

No, that would be pointless. That's no different than passing the zenid as a GET parameter, which you said you can't do in the first place.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Oct 2010, 8:11 AM
#11
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #11 by twowayradio

I was just thinking as ZC seems to need that get then if I stored it in a session value then if the session value held for the couple of mins the customer was on the Barclays payment page it would be a way of passing back the info to Zen after the Barclays payment. I can't pass it as a GET or POST because Barclays don't have any spare fields.

Failing that is there anything else I can try, switching hosts and merchant accounts unfortunately isn't an option. Nor do I want to force cookie usage if I can avoid it...

27 Oct 2010, 8:47 AM
#12
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #12 by twowayradio

Another interesting fact I've just noticed...

IF HTTP friendly error messages are enabled in the browser then the user gets a IE 404 error page. If friendlys are switched off on the browser then the user gets the Zen Cart Whoops page.

The 404 is on http://{correct-secure-url}/edpq_cpi_handler.php - which is a page that exists ok and is outside of the protected folder.

Here's the code from epdq_cpi_handler.php

<?php
/**
 * ePDQ results handler
 *
 * @package page
 * @copyright Copyright 2008 Kuroi Web Design
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: epdq_cpi_handler.php 263 2008-10-30 02:01:11Z kuroi $
 */

require('includes/application_top.php');

if (EPDQ_REDIRECT_WORKING) {

  if (isset($_GET['oid']) && !empty($_GET['oid'])) {
    $sql = "select transactionstatus
            from " . TABLE_EPDQ_LOG . "
            where oid='" . $_GET['oid'] . "'
            order by timestamp desc
            limit 1";
    $txn = $db->Execute($sql);
    if ($txn->RecordCount() <= 0) {
      $fatalError = 'temporary order ID ' . $_GET['oid'] . ' not recognised in ePDQ log table';
    } elseif (substr($txn->fields['transactionstatus'],0,7) != 'Success') {
      $paymentWarning = 'Payment ' . strtolower($txn->fields['transactionstatus']);
    }
  } else {
    $fatalError = 'Temporary order ID not passed as parameter from ePDQ';
  }

  if ($fatalError) {
    $logFile = DIR_FS_CATALOG . 'epdq/logs/epdq_' . date('ymdHis') . '.log';
    if (file_exists($logFile)) unlink($logFile);
    $handle = fopen($logFile, 'a');
    fwrite($handle, $fatalError . "\n");
    fclose($handle);
    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=technical_problem.html">';
  } elseif ($paymentWarning) {
    $messageStack->add_session('checkout_payment', $paymentWarning, 'error');
    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=index.php?main_page=checkout_payment">';
  } else {
    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=index.php?main_page=checkout_success">';
  }

} else {

  exit('<meta HTTP-EQUIV="REFRESH" content="0; url=index.php?main_page=checkout_process&oid=' . $_GET['oid'] . '">');

}
?>
27 Oct 2010, 4:52 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #13 by drbyte

What does your server's error-log say as the cause of the 404 error?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Oct 2010, 8:20 AM
#14
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #14 by twowayradio

DrByte:

What does your server's error-log say as the cause of the 404 error?

The only error that I can see is...
dksales is the folder that I have a second copy of the site in, which Fasthosts links to for the SSL. dksales = https://secure9.prositehosting.co.uk/dksales/

[27-Oct-2010 09:27:57] PHP Warning:  Call-time pass-by-reference has been deprecated in /home/linuxweb09/d/url.co.uk/user/htdocs/dksales/includes/modules/payment/epdq.php on line 91
[27-Oct-2010 09:27:57] 

URL.co.uk is the website address, just changed that now. Thanks again for your help with this.

28 Oct 2010, 8:40 AM
#15
twowayradio avatar

twowayradio

New Zenner

Join Date:
Oct 2010
Posts:
32
Plugin Contributions:
0

Post #15 by twowayradio

I'm not sure if it is that causing it though. epdq.php is the page prior to the jump page outbound to Barclays. Barclays is posting back data because the transaction show as approved/declined in the ZC ePDQ log.

Line 91...

// open socket to filehandle(epdq encryption cgi)
$fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );

28 Oct 2010, 12:34 PM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #16 by drbyte

TwoWayRadio:

The only error that I can see is...
dksales is the folder that I have a second copy of the site in, which Fasthosts links to for the SSL.
dksales = https: //secure9.prositehosting.co.uk/dksales/

URL.co.uk is the website address, just changed that now. Thanks again for your help with this.
See, we've had this discussion here on the forum already.
Fasthosts does SSL in a very unconventional way, and is basically the only hosting company still stuck in the dark ages with their approach to that. It's entirely possible that all your problems are directly related to that.
The completely-separate site could be exactly what's causing the lost session. You even confirmed that yourself when you turned off SSL and suddenly everything magically worked.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.