Zen Cart Logo
Forums / Addon Payment Modules / How does Zencart re-create the Session from zenid, say for a callback URL for payment

How does Zencart re-create the Session from zenid, say for a callback URL for payment

Locked

Views: 7,256

Results 21 to 26 of 26
This thread is locked. New replies are disabled.
27 Jun 2009, 5:38 PM
#21
infocom avatar

infocom

Zen Follower

Join Date:
Jul 2006
Location:
Cardiff, Wales
Posts:
308
Plugin Contributions:
0

How does Zencart re-create the Session from zenid, say for a callback URL for payment

I thought it worked, and then I had 2 orders, the first from the callback I thought, the second from when the customer returned to the site. Then it didn't work at all anymore. When I get back to the pc I think I'll post the callback file here.
Posted via Mobile Device

27 Jun 2009, 6:10 PM
#22
infocom avatar

infocom

Zen Follower

Join Date:
Jul 2006
Location:
Cardiff, Wales
Posts:
308
Plugin Contributions:
0

Re: How does Zencart re-create the Session from zenid, say for a callback URL for payment

this is the main file without a couple of functions which work OK, like the IdentityCheck() and showError(). It passes the identity check because my writeStatus() function (also not shown) writes the value "1" to the file, used to determine the stage below. So I know it processes writeStatus($_POST, "1"); Then it does not do the CURL. I have also tried the original header Location redirect commented out instead of the CURL, which also fails. If I by pass the checks below straight to the header and go to the callback file in my browser, the header redirect does work. So this is why it seems the gateway fails at the header or CURL stage.

As stated though... if I entered the index.php?main_page=checkout_process&zenid=xxxx on another computer, I get a "Whoops Session expired" message, but it works when entered on the computer I have logged into the store and made the order with. This is why I think maybe the header and CURL IS working, but the issue is the URL index.php?main_page=checkout_process&zenid=xxx is not working when called from another computer. Just a hunch.

if ($_POST['transStatus'])
{
	if($_POST['transStatus']=='Y')
	{
		$IdentityCheck = IdentityCheck();

		if ( (strcmp ( $_POST ['IdentityCheck'], $IdentityCheck ) == 0))
		{
			writeStatus($_POST, "1");
			//header('Location: index.php?main_page=checkout_process&zenid='.$_POST['donorref']);
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, 'http://www.mydomain.org.uk/index.php?main_page=checkout_process&zenid='.$_POST['donorref']);
			curl_exec($ch);
			curl_close($ch);
		}
		else
		{
			writeStatus($_POST, "2");
			showError();
		}
	}
	else
	{
		writeStatus($_POST, "3");
		showError();
	}
}
else
{
	writeStatus($_POST, "4");
	showError();
}
27 Jun 2009, 6:42 PM
#23
philip_clarke avatar

philip_clarke

Suspended

Join Date:
Sep 2008
Posts:
608
Plugin Contributions:
3

Re: How does Zencart re-create the Session from zenid, say for a callback URL for payment

I don't think you are quite correct, I have just created the session

http://www.kcm.org.uk/shop/index.php?main_page=shopping_cart&sort=20a&products_id=643&zenid=xxxxxxxxxxxx

( where literally the zenid is xxxxxxxxxxxx ) in the UK and then logged onto the site as a guest from germany and the shopping cart is the same.

27 Jun 2009, 6:43 PM
#24
philip_clarke avatar

philip_clarke

Suspended

Join Date:
Sep 2008
Posts:
608
Plugin Contributions:
3

Re: How does Zencart re-create the Session from zenid, say for a callback URL for payment

If you go to the above URL btw, I am refreshing the cart every so often, so you should see it pop up if you are not logged in.

Philip.

28 Jun 2009, 12:39 AM
#25
infocom avatar

infocom

Zen Follower

Join Date:
Jul 2006
Location:
Cardiff, Wales
Posts:
308
Plugin Contributions:
0

Re: How does Zencart re-create the Session from zenid, say for a callback URL for payment

OMG :shocking: I think I've done it.

From your post of the following code I only just noticed the GET zenid will only be processed if its a SSL! I dont have a SSL so the session was not being recreated!

if (isset($_POST[zen_session_name()])) {
  zen_session_id($_POST[zen_session_name()]);
} elseif ( ([B]$request_type == 'SSL'[/B]) && isset($_GET[zen_session_name()]) ) {
  zen_session_id($_GET[zen_session_name()]);
}

Oh such a simple thing that was overlooked!!!

So I could not use header redirect anyway as this is GET not POST, and have now got the POST working OK via CURL.

So the callback file will first run the checks to make sure its come back from the payment gateway, and then use CURL to post the zenid to checkout_process. There are then some variables passed to this that the before_process() uses to check that its come from the gateway so you cant use checkpout_process to override the order.

Thanks a lot for your help. There are a couple of things I want to tidy up, but seems to work. The only thing is the $_SESSION['payment'] was not being set as the payment gateway on the Shopping Cart page, so if you went to checkout_process it would not call the before_process() as it didnt have a payment module loaded, so the order was processed anyway. I cannot see how to load the payment module in the session at the shopping cart stage (it does it as payment page) so in the meantime I have had to hard code the payment gateway to load into the session everytime. I dont suppose you know how the payment module gets loaded into the $_SESSION['payment'] on the main_page=shopping_cart do you so I dont have to hard code it? My code looks to be the same as all other gateways. V strange.

28 Jun 2009, 6:54 AM
#26
philip_clarke avatar

philip_clarke

Suspended

Join Date:
Sep 2008
Posts:
608
Plugin Contributions:
3

Re: How does Zencart re-create the Session from zenid, say for a callback URL for payment

If you dump out the contents of $order and $_SESSION using print_r in the checkout_confirmation page, you'll find that there is payment_method_code or payment_module_code set when the person leaves the site, that should then recreate the module when they come back. Can't remember which at the moment, probably the order object thinking about it. Bit too early for me this morning

Philip.