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
Code:
if ($testMode !== 0) {echo WP_TEST_HEADING . "<br /><br />";}
to
Code:
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
Code:
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
Code:
zen_draw_hidden_field('testMode', MODULE_PAYMENT_WORLDPAY_TEST_MODE) .
to
Code:
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
Code:
if(isset($HTTP_POST_VARS['testMode'])) {$testMode = $HTTP_POST_VARS[testMode];}
to
Code:
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
Bookmarks