Forums / Addon Payment Modules / WorldPay Module for ZenCartv1.3x

WorldPay Module for ZenCartv1.3x

Locked

Views: 137,250

Results 61 to 80 of 464
This thread is locked. New replies are disabled.
29 Aug 2006, 10:47 PM
#61
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

WorldPay Module for ZenCartv1.3x

Rikki,

Doesn't appear to be anything wrong with your language file either - it was a bit of a longshot anyway.

I did a quick search on Google to see if there were any reported bugs for the IF statement in any paticular version of PHP. I didn't find anything but I didn't pursue it too hard.

I am no PHP expert but my understanding is that when you are testing for a numerical value you do not use quotes.

if ($testMode !== 0) {echo WP_TEST_HEADING . "<br /><br />";}

However if you are testing for a string value, ie text, you do use quotes

if ($testMode !== "zero") {echo WP_TEST_HEADING . "<br /><br />";}

You could try using quotes in case the value 0 is being presented as text rather than as a number although if that were the case I would expect the transaction to fail at WorldPay. (I've just looked this up in the WorldPay integration Guide which states " . . . Set this parameter to "0" or omit it for a live transaction." Perhaps it wouldn't fail then!?)

On re-reading the syntax for IF statements it would appear than the curly brackets surrounding the executable code is not strictly necessary if there is only one line of executable code so you could try:

if ($testMode !== "zero") echo WP_TEST_HEADING . "<br /><br />";

Make only one change to your code then test it. If it doesn't work change things back and try another change. Otherwise you can make an awful mess of things and you can easily lose track of what caused what.

If either of the above works let me know.

I'll reply to your PM tomorrow.

Regards,

Alan

workingIT.co.uk
working IT for business

30 Aug 2006, 12:45 AM
#62
rikki avatar

rikki

New Zenner

Join Date:
Mar 2006
Posts:
17
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

After adding quotes around the IF statement:
**
removed humongus screenshots**

Ta-da!

I always thought PHP was clever with its variable assignments and could swap between string and numerical no problem at all but when its dealing with variables passed through to other scripts it must interpret everything as a string and therefore the : IF ($testdata !== 0) { ... } statement would be read as being "IF $testdata is NOT false display the test transaction message" as a comparison to 0 is a test for the variable existing/having data inside.

This is just what I reckon is going on with my limited PHP/C knowledge from a few years ago, I stopped doing all that and got more into making things look pretty as its easier to fix when things go tits up :D

The curious thing is though, why is it only this installation that is affected by this? Surely there must be a lot of other folks with your gateway system installed.

Anyway, I think thats it sorted out (I hope) so thanks for your continued support and help.Drop me a reply tomorrow regarding the PM and I can hopefully put some business your way, its the least I can do.

Many thanks,

Rikki

30 Aug 2006, 11:25 AM
#63
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Rikki,

Firstly, for clarity, the solution to your problem is to change includes/templates/template_default/templates/tpl_wpcallback_default.php at lines 208 and 321 from

if ($testMode !== 0) {echo WP_TEST_HEADING . "<br /><br />";}

to

if ($testMode !== "0") {echo WP_TEST_HEADING . "<br /><br />";}

I've been doing some research and some testing to try to get to the bottom of this.

My understanding is that PHP handles variables in context. In lay terms if the context is numerical ie mathematical operands are in use like + - etc then PHP treats the variable as a number. If the contect is textual it treats the variable as a string.

The conclusion I have come to is that it shouldn't matter which way the above code is written. It works both ways for me. You seem to be the only one to have experienced this problem - at least the only one to have reported it. What version of PHP is installed on your server?

I also wanted to understand exactly what is hppening here in terms what 'type' of variable $testMode actually is.

The value of $testMode is stored in the database in the 'configuration' table as the 'configuration-value'. In the database 'configuration_value' is a text field so it follows that the default type for $testMode will be 'string'.

I set up a test to display the type of the variable $testMode

echo '$testMode type = ' . gettype($testMode) ."<br /><br />";

The result? $testMode is indeed a string.

According to WorldPay $testMode should be sent to them as an integer so I changed the code which sets the value of $testMode in includes/modules/payment/worldpay.php at line 138 from

zen_draw_hidden_field('testMode', MODULE_PAYMENT_WORLDPAY_TEST_MODE) .

to

zen_draw_hidden_field('testMode', intval(MODULE_PAYMENT_WORLDPAY_TEST_MODE)) .

This I think should set the type to integer. However the value returned by WorldPay is still of type string.

I then changed line 42 in includes/templates/template_default/templates/tpl_wpcallback_default.php from

if(isset($HTTP_POST_VARS['testMode'])) {$testMode = $HTTP_POST_VARS[testMode];}

to

if(isset($HTTP_POST_VARS['testMode'])) {$testMode = intval($HTTP_POST_VARS[testMode]);}

This change resulted in the type being set to integer so this change should make the original code work on your server. However the easiest change is just to add the quotes as you have done. This too should work in all cases - unless anyone else knows differently!

I'll consider this change for the next version which I will be working on soon.

Regards,

Alan

workingIT.co.uk
working IT for business

30 Aug 2006, 8:15 PM
#64
rikki avatar

rikki

New Zenner

Join Date:
Mar 2006
Posts:
17
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Yeah, this seems to be it sorted now thankfully.

When passing a variable from a script to another script it will be turned into a string no matter what as there is no data format on the web for POST or GET commands, everything is in ASCII and should be sanitized when it arrives at the receiving script.

Its amazing that this should crop up right here and right now as I had just finished listening to a Podcast by PHP inventor Rasmus Lerdorf and he specifically talks about just such things!

http://www.twit.tv/FLOSS

In particular : http://www.podtrac.com/pts/redirect.mp3?http://twit.cachefly.net/FLOSS-012.mp3

At time point 38:35

Have a listen :D

BTW (PHP Version 4.4.2) is whats running on my server here FYI. Still puzzled as to why Im the only one to spot this problem, but happy its sorted out and I've learned something along the way too.

Kind regards,

Rikki

30 Aug 2006, 9:29 PM
#65
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Rikki,

Just had a listen. Very interesting - but I'm not sure I understood it all!

My servers running PHP version 4.3.11.

I suppose if the data arrives as text the correct thing to do is to treat it as text and code accordingly in which case your solution is the better coding practice.

Well as they say "Every day's a school day!"

All the best,

Alan

workingIT.co.uk
working IT for business

31 Aug 2006, 12:39 AM
#66
tigerbalm avatar

tigerbalm

New Zenner

Join Date:
Jan 2006
Posts:
15
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hi Alan / Rikki,

Read your conversation with interest. I have exactly the same problem to the letter - as you Rikki.

Firstly, I don't know which solution to test out - Rikki's or Alan's - Rikki's seems less hassle and likelyhood of human error as it's a quick change - but Alan's seems the more correct solution if you're a dab hand at PHP - hhhhmnnnnn

What do you both suggest ....

Also - there's nothing worse than to solve a problem but not understand where it's coming from - ie: why only you and I Rikki? - so I'm with you on that one ...

For my 2pence worth - I'm running PHP as a CGI module which is not the best way for a zen cart installation - I'm wondering are you Rikki and do either of you think this would have any bearing on this particular problem??

For the record - here are my settings ...

Server OS: FreeBSD 4.10-STABLE
Database: MySQL 4.1.19
PHP Version: 4.3.10 (Zend: 1.3.0)
HTTP Server: Apache

Another quick one though not important - V1.3 is compliant but the worldpay image sidebox causes serious havoc with the validator. I'd sort this out myself if I could but I'm not confident enough to tackle someone elses code :o( - - - yet!

On a final note - cheers for your convo guys and to yourself Alan - well what can I say - thanks a bunch!

duncanad:

Rikki,

Just had a listen. Very interesting - but I'm not sure I understood it all!

My servers running PHP version 4.3.11.

I suppose if the data arrives as text the correct thing to do is to treat it as text and code accordingly in which case your solution is the better coding practice.

Well as they say "Every day's a school day!"

All the best,

Alan

31 Aug 2006, 5:06 AM
#67
tigerbalm avatar

tigerbalm

New Zenner

Join Date:
Jan 2006
Posts:
15
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hi Guys,

Ok - so I put the quotes in as per what Rikki did and all is fine and working properly so thanks!

Now another problem crops up and I don't know whether it's an issue with the worldpay module, or the discount coupons but here's my problem ...

Everything works fine, I'm running the latest worldpay and zencart and all is perfect and fully tested by me before going live.

The first purchase that comes through after the upgrade is completed appears in the new orders but the money hasn't come through to worldpay (my configuration of both WP and zen is perfect)

The customer is trusted and contacts to advise that she received the checkout success page after clicking the final confirm and was at no time transfered to worldpay - and her order is in my database.

I promptly freak out and over the next few hours try to replicate her order. By process of isolation of all possible parameters individually, I worked out it was the discount coupon that was creating the problem. Just to make sure, I tested like this ...

  1. Created a discount coupon for 10%

  2. Created an account

  3. Put some products in the basket and successfully ended up at the Worldpay payment page

  4. Cancelled the payment at Worldpay, went back to the site, deleted a couple of products and added some more - once again successfully getting to the payment page

  5. Repeated steps 3 and 4 over 60 times - successfully

  6. Repeated the process once more but this time I added the discount coupon and when I clicked final confirmation - expecting the WP page - I was held for a couple of seconds and directed to the checkout success page - on checking, my order was in the database but I never went near Worldpay

  7. It must be stressed that during my extensive testing, the discount coupon worked successfully with payment page many times - that's what confuses me and that's what makes it so difficult to pinpoint the problem

So This looks like a discount coupon problem. What made me think it might be Worldpay is that Alan mentioned somewhere else on this thread - that the order is not completed and entered until the call back is received from WP - so by that reckoning, could it have bounced off worldpay to get success? I contacted WP who assured me that they did not recieve any contact to my account during the offending 'purchases'

kind regards :o)

Any ideas - I'm sure all my settings are correct - I have checked and double checked and

31 Aug 2006, 9:18 AM
#68
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Tigerbalm,

I'm a great believer in the KISS principle - the simple solutions are always best. I'd go with Rikki's 'just add quotes' solution and the next version of the mod will have this change. I see this is what you have done and it works for you too.

Like you I'm puzzled by why this has been a problem for some but not others. As I said above I believe PHP sets data type according to context. Perhaps in this instance there is not really any numerical context other than not having used quotes ie there are no mathematical operands used so perhaps its pot luck whether PHP handles it correctly or not. If there are any PHP gurus out there perhaps they may be able to shed some light.

Your Discount Coupon problem is a new one on me. Sounds to me as though ZenCart thinks there is sufficient value in the coupon to cover the whole cost of the order, in which case there would be no need to go through the WorldPay process and it would be quite correct to jump straight to the 'Checkout Success' process creating the order and displaying the standard 'Checkout Success' page - not the 'WorldPay Callback' page.

At the risk of being just a bit too obvious are you sure you created a 10% discount coupon and not a £10 discount coupon? A £10 discount coupon would produce the result you are experiencing if the total value of the sale was £10 or less? (Or even a 100% discount coupon!!!)

I don't think this is a WorldPay Module issue since there is nothing in the module code that looks at whether a coupon is being used or not. This is handled by the Orders Total module.

With regards to the 'We accept ...' sidebox I'll ensure that this is standards compliant for the next release. In the meantime have a go yourself. It's only HTML.

includes/templates/template_default/sideboxes/tpl_wp_cc_accept.php

I suspect the main problem is that it is just a row of images with nothing separating each one which is non compliant markup. I did it that way so that the display would be fluid and would adjust itself according to whatever width the sidebox happens to be. Seemed like a good idea at the time!

Keep us posted of any developments with your Discount Coupon problem.

Regards,

Alan

workingIT.co.uk
working IT for business

3 Sep 2006, 10:51 PM
#69
rikki avatar

rikki

New Zenner

Join Date:
Mar 2006
Posts:
17
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

duncanad:

Rikki,

Just had a listen. Very interesting - but I'm not sure I understood it all!

My servers running PHP version 4.3.11.

I suppose if the data arrives as text the correct thing to do is to treat it as text and code accordingly in which case your solution is the better coding practice.

Well as they say "Every day's a school day!"

All the best,

Alan

I've got into pod casts lately, TWIT is pretty good and the FLOSS ones can be hit or miss but the best one is Security Now with Steve Gibson. https://www.grc.com

Not sure I understand it all, if any, but it was ironic that the bloke mentioned something I'd remember when looking at the code in the WP gateway scripts.

Kind regards,

Rikki

6 Nov 2006, 10:37 PM
#70
bigmacyin avatar

bigmacyin

New Zenner

Join Date:
Feb 2006
Location:
UK
Posts:
30
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

I would just like to thank all involved in this thread. I too had exactly the same problem as Rikki and couldn't get rid of the test transaction text. I copied tpl_wpcallback_default.php file to my templates folder and added the quotes as suggested but it didn't resolve the problem. I then used Alan's information, changed the if statement and all is now working fine.

Thanks again to all concerned and I hope that helps someone else.

Kind regards,

Hamish

Big H

7 Nov 2006, 9:40 AM
#71
ces avatar

ces

Zen Follower

Join Date:
Nov 2004
Location:
West Mids, England
Posts:
199
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hi

I know a few people have requested the order id to be sent to the worldpay gateway so that they can reconcile the orders to the payments.

And I understand that the order id is not raised until zencart gets the callback from worldpay.

Would a compromise be that the customer id be sent to worldpay and returned to zencart. An account is created before going to the final checkout and an id would have been created. Most days a customer will only order once and it would be much easier to match up payments to customers and therefore orders.

I have no idea at implementing this but i thought I would mention it. It may be a stupid idea but I would appreciate comments.

Craig

7 Nov 2006, 10:24 AM
#72
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hamish,

Now I am confused! It's either numerical or a string. I've proved it is a string when it comes back from WorldPay so 'just add quotes' should work fine in all cases. Anybody got any clue why this simple snippet of code is not producing consistant results?

Craig,

As you rightly say you cannot send the order id to WorldPay since the order is not created until the 'success' response is received back from WorldPay.

One possibility is to store the WorldPay transaction ID in the database and display this in the orders listing in admin. This would give a cross reference within Zencart but not in the WorldPay control panel. The WorldPay control panel does store the session ID but this doesn't help.

I have thought of sending the cart ID rather than the session ID to WorldPay but I need to look into the implications of this in more detail. This would help in two ways.

  1. If this were stored with the order data and displayed on the orders listing within Admin then we would have a common reference in both ZenCart Admin and the WorldPay control panel.

  2. On the rare occasion when the transaction is successful at WorldPay but the callback fails the merchant can retrieve the order information from the cart ID.

NB The circumstance under which a credit card transaction is successful but the callback fails would be if the merchant host server went down while the WorldPay transaction was taking place. The callback would fail because the host server would be unavailable at the time of the callback. This has happened once in over 1500 orders to a customer of mine.

Your premise that the customer ID could be used on the basis that a customer is unlikely to make two orders on the same day is flawed. Although not common it is not unknown, which brings us inevitably to good old Murphy's Law - If it can go wrong - it will!

http://www.murphys-laws.com/

Any further thoughts on this subject would be appreciated.

Regards,

Alan

workingIT.co.uk
working IT for business

7 Nov 2006, 12:05 PM
#73
ces avatar

ces

Zen Follower

Join Date:
Nov 2004
Location:
West Mids, England
Posts:
199
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Thanks for the quick reply Alan.

Might have guessed my idea was a non-starter, although for my use would probably be OK.

However, I did not realise the card ID was held by ZenCart at all. Sounds as if it would be good.

Look forward to more peoples thoughts on it.

Craig

9 Nov 2006, 6:44 AM
#74
bigmacyin avatar

bigmacyin

New Zenner

Join Date:
Feb 2006
Location:
UK
Posts:
30
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hi Alan,

I wish I knew and could help. I have come to the assumption that none of this is to be clear to me!!

I wanted to ask whether anyone had had an issue with the callback page showing secure and non secure items? I had your module on a 1.2.7 store and it worked great. I have now installed it on my new 1.3.6 version and when I make a payment, an error message pops up saying the page has both secure and non secure items on it.

When I click No to accept the secure items, the design of the page disappears and all I get is a text layout without the styling.

Any help would be greatly appreciated.

Many thanks.

Hamish

Big H

10 Nov 2006, 9:44 AM
#75
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hamish,

The 'Non secure items on the page' message is generated by your browser and simply means that within a page which is accessed securely by HTTPS (ie the URL starts https://...) some items are linked to non-securely by HTTP (ie the URL starts http://...) Usually the non secure links are to images and therefore there is no security issue with clicking 'Yes' in response to the message. However it would be better all round, not least for your customers' peace of mind, if this message was not displayed.

To find out where the non secure links are make a test transaction and when the message appears click 'Yes'. Now view the source of the resultant page. In Internet Explorer you click on 'View' on the menu bar and then on 'Source'. This opens the page code in 'Notepad'. Now search the source code for the string 'http://'. In notepad click 'Edit' on the menu bar and then 'Find Next'. Make a note of which links are non-secure and edit the appropriate Zencart file to correct this.

My guess is that you have placed an image in one of your sideboxes where you have hard coded the link as something like:

<img src="http://www.mysite.com/myimage.jpg" />

Changing this to

<img src="https://www.mysite.com/myimage.jpg" />

will solve the problem.

Hope this helps.

Alan

workingIT.co.uk
working IT for business

10 Nov 2006, 12:06 PM
#76
unifex avatar

unifex

New Zenner

Join Date:
Mar 2006
Posts:
12
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

I allways get .. “your payment has been cancelled!”

I don’t know what´s wrong but the callback fails in my shop. I use Zen 1.35 and PHP Version: 5.1.5 .

If I make an order in the shop, and use this modul, all works fine until the callback starts.

The callback takes me back in my Shop with the message:

... your payment has been cancelled!
Response from WorldPay:

This is a TEST TRANSACTION. No money has changed hands

Your payment has been cancelled…

Later I get a message from Worldpay that all works fine with no error. Why I get the wrong message with “Your payment has been cancelled…”?

The Money changed from the customer to me but the shop can´t complete the order of the customer.

Can someone help me ?

10 Nov 2006, 12:46 PM
#77
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Unifex,

Since you are using PHP version 5.1.5 it sounds as if you have encountered the same problem as Michaelchild did some time ago in this thread.

You will find his solution here:

http://www.zen-cart.com/forum/showpost.php?p=229504&postcount=32

and you will find an explanation as to why this solution is needed here:

http://www.zen-cart.com/forum/showpost.php?p=248440&postcount=41

There is another possibility that you are encountering a problem which some (but not all) users seem to have come across. This has to do with the way PHP handles the test in the script for the value of $testMode which is returned by WorldPay as part of their response token. The 'just add quotes' solution posted here SHOULD work in all cases.

http://www.zen-cart.com/forum/showpost.php?p=253886&postcount=63

To risk teaching my granny to suck eggs do one change at a time testing thouroughly each time.

Hope this helps.

Regards,

Alan

workingIT.co.uk
working IT for business

10 Nov 2006, 12:54 PM
#78
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hamish,

While replying to Unifex (see above) it occured to me that your problem might have been related to PHP v 5.1 which might explain why the 'Just add quotes' solution didn't work for you. What version of PHP is installed on your server?

I just hate not knowing why something works or doesn't!

Regards,

Alan

workingIT.co.uk
working IT for business

10 Nov 2006, 5:24 PM
#79
unifex avatar

unifex

New Zenner

Join Date:
Mar 2006
Posts:
12
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Halleluja,

okay, i don´t believe in god but in fast support of technical problems. Solution one works for me.

Thanks Alan for your help.

Regards,

Unifex

13 Nov 2006, 1:57 PM
#80
bigmacyin avatar

bigmacyin

New Zenner

Join Date:
Feb 2006
Location:
UK
Posts:
30
Plugin Contributions:
0

Re: WorldPay Module for ZenCartv1.3x

Hi Alan,

Sorry for the delay in my reply - I didn't get the email to say someone had added to the thread.

With regards which version of PHP my server is using, I am afraid I don't have good news if you think the problem is with version 5. I have 4.4 installed according to the server info in admin.

Also, thank you for your detailed reply about the images. I have had a quick look and can't spot it but I will look in a little more depth when I get 5 mins.

Many thanks again for your help.

Kind regards,

Hamish

Big H