Jump to content

Worldpay redirection issue - Worldpay module


sixthmind

Recommended Posts

I hope somebody can help with this one.

I managed to make a test transaction through Worldpay which is executed after I click on Make payment. However, for some reason it doesn't redirect back to the website and instead we get Not found message refering to validation.php

 

Anybody had this issue and managed to resolve it?

Any help would be really appreciated.

Link to comment
Share on other sites

  • 2 weeks later...

Right, I've installed the module and have received authorisation from WorldPay so it's all set to live.

I've set the call-back url in WorldPay's settings to /modules/worldpay/validation.php

 

WorldPay authorise the transaction and I can see that the browser briefly hits validation.php before being redirected to the order-confirmation page. That page just says "You haven't placed any orders" and the order doesn't show up in Back Office.

 

It's quite difficult to debug this since I have to keep placing real orders and there's nothing obviously going wrong.

 

Assistance is required.

Link to comment
Share on other sites

I'm going to detail my progress here as I go just because this, as far as I can tell (for £200), should just work out of the box but it clearly doesn't.

 

Ok, so the validation.php script seems to have all the correct variables present in the GET array so it redirects to:

 

'order-confirmation.php?id_module='.$worldpay->id.'&id_cart='.$cart->id.'&key='.$customer->secure_key

 

So, next stop is the preProcess method in the ORderConfirmationControllerCore class.

 

At line 50:

 

$this->id_order = Order::getOrderByCartId((int)($this->id_cart));

 

This is returning false. $this->id_cart is #9, but the resulting id_order is false, so the OrderGetOrderByCartId() is unable to locate an order.

 

I figure then that the order was supposed to have been initialised before the redirection to WorldPay, so the hunt moves to finding out where that's supposed to happen

Link to comment
Share on other sites

It doesn't. The request in the callback from WorldPay contains no $_POST data. I checked.

The validation script looks like this:

 


if(isset($_POST['cartId']))
{
$cart = new Cart(intval($_POST['cartId']));
if (!Validate::isLoadedObject($cart))
exit;

$customer = new Customer($cart->id_customer);

/* Loading the object */ 
$worldpay = new worldpay();
$feedback = $worldpay->l('Message:').$_POST['rawAuthMessage'];

if ($_POST['transStatus'] == "Y")
$worldpay->validateOrder(intval($cart->id), _PS_OS_PAYMENT_, $_POST['amount'], $worldpay->displayName, $feedback, array(), NULL, false, $customer->secure_key);
else
$worldpay->validateOrder(intval($cart->id), _PS_OS_ERROR_, $_POST['amount'], $worldpay->displayName, $feedback, array(), NULL, false, $customer->secure_key);

Tools::redirect('order-confirmation.php?id_module='.$worldpay->id.'&id_cart='.$cart->id.'&key='.$customer->secure_key); 
}else
{ 
$cart = new Cart(intval($_GET['cartId']));
$customer = new Customer($cart->id_customer);
$worldpay = new worldpay();
Tools::redirect('order-confirmation.php?id_module='.$worldpay->id.'&id_cart='.$cart->id.'&key='.$customer->secure_key);
}

 

It passes through the else of that conditional. I'll check what data comes through and see if it has everything in the $_GET array that it needs and copy/paste those lines into the else part.

 

Either that or see if there's a setting on WorldPay to force $_POST variables.

Link to comment
Share on other sites

WorldPay had no option to use $_POST variables so I had a look at what it was actually sending across and changed the else part to:

	$cart = new Cart(intval($_GET['cartId']));
	$customer = new Customer($cart->id_customer);
	$worldpay = new worldpay();
	if (isset($_GET['paymentStatus']) && $_GET['paymentStatus'] == "AUTHORISED"){
		$worldpay->validateOrder(intval($cart->id), _PS_OS_PAYMENT_, $_GET['paymentAmount'], $worldpay->displayName, $feedback, array(), NULL, false, $customer->secure_key);
	}
	else{
		$worldpay->validateOrder(intval($cart->id), _PS_OS_ERROR_, $_GET['paymentAmount'], $worldpay->displayName, $feedback, array(), NULL, false, $customer->secure_key);
			}
	Tools::redirect('order-confirmation.php?id_module='.$worldpay->id.'&id_cart='.$cart->id.'&key='.$customer->secure_key);

I get an alert that there was a problem with the order but I think that's just because it's in test mode again, but the order does at least now show up in back office.

I'm assuming that the differences between what this module expected and what I was getting may be down to the country. I'm in the UK, so clearly wouldn't expect the paymentStatus element to contain AUTHORISED when in the U.S.

 

I think some work may need to be done by the prestashop team on updating this module for international use.

I've also got no idea at this stage what other strings may be contained within the paymentStatus element. It would be nice to have a list to that I can redirect accordingly. I'm sure it's not just AUTHORISED and DECLINED.

 

Edit: The paymentAmount comes back in pence so that needs dividing by 100. The confirmation page I just went to said I'd been charge £2215.00 instead of the petty cash I was expecting to spend.

 

Edit2: Thanks for your help. Apologies for hijacking the original thread. I believe the answer to the original question is that you need to log into your WorldPay account and change the installation settings and put in your callback URL (http://yourdomain.com/modules/worldpay/validation.php)

Edited by rf_leenoble (see edit history)
  • Like 1
Link to comment
Share on other sites

so if worldpay does not POST back the information, but is instead placing the variables in the query string (aka GET), then the validation.php has a bug, since it does not invoke validateOrder.

 

You can use the Tools::getValue function to deal with that, since that function will look at both POST and GET, shielding you from having to deal with that.

 

so where are you with the issue? having configured worldpay now, and revising the validation.php script, are things working?

Link to comment
Share on other sites

  • 2 weeks later...

i'm using version 1.4.7.3. I guess I won't upgrade to the latest version just yet then.

 

Do you know (or anybody at Prestashop *nudge nudge*) why the module isn't compatible with 1.4.8.2? Is it anything to do with the bit I've rewritten to make it work with my installation?

 

Come on Prestashop! What are you playing at? Not offering any kind of support here to people who've paid money in good faith for a WorldPay module and not even supporting your own latest software. This is p-poor.

Edited by rf_leenoble (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

Hi

 

Is this working on prestashop 1.5.2?

 

Thanks.

 

My clients is considering purchasing this module for their new Prestashop store. Before they do, can I just check to see if the issues within this module have now been rectified and if it is compatible with 1.5.2?

 

Thanks in advance,

 

David

Edited by Davie Smith (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Considering the ridiculous amount of money they're charging for this module (there is not actually very much code in it!), the support is absolutely pathetic!

 

I posted in another thread (before I found this one) about the issue I'm having - the final re-direct to "order_confirmation" does not work. The customer is just left "hanging" on a blank page after return from Worldpay!

 

This is a major issue and should be getting resolved immediately (if it was a FREE module one would expect very little support but when paying EUR200.00 for a module, the support should be shit hot!

 

I'm getting really annoyed with this now. I'm also having the exact same issue with the "Payment by Cheque" module. Weirdly, the "Bank Wire" module is working as advertised!?!

 

Do I recall correctly seeing something somewhere about a "URL too long" issue??

Link to comment
Share on other sites

OK...

 

Doing a bit of my own debugging here, this is what is sat in the address bar of the browser when it hangs:

http://MYSITE.co.uk/modules/worldpay/validation.php?cartId=49&orderKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&paymentStatus=AUTHORISED&paymentAmount=1050&paymentCurrency=GBP&mac=5728fae317bacd5aa6cd8e1c62623c34&source=WP

 

and this is what is what is in the array within "validation.php":

Array ( [cartId] => 50 [orderKey] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXX [paymentStatus] => AUTHORISED [paymentAmount] => 1050 [paymentCurrency] => GBP [mac] => ef7520b218bb5d1f83f125921871b598 [source] => WP [controller] => pagenotfound )

The significant part seems to be the last part maybe!?!

 

[controller] => pagenotfound

 

So, could this be the issue perhaps? The controller function is missing from this fantastic bit of EUR 200 coding???!!!!!

 

EDIT: Yes, I know the cart IDs are not the same - I added the code to throw up the array on the second one.

Edited by Porpoise (see edit history)
Link to comment
Share on other sites

  • 2 months later...

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
×
×
  • Create New...