I'm working on an easy way to do edit the status of an Paypal payment system so i can switch it over in test mode when needed without going into the code. "MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER" is defined to "Live", but for some reason it keep throwing the sandbox url.
echo MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER ;
if (MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == "Live") {
$form_action_url = 'https://www.paypal.com/cgi-bin/webscr';
} else {
$form_action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
}
echo ' '.$form_action_url;
die();
The above outputs:
If I replace MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER with 'live' it returns the value correctly, I also tried to move the DEFINE to a Variable before it goes to the IF statement, but it still doesn't work.
I'm using OsCommerce to define this via the admin system.
var_dump also shows:
string(20) "Live"
instead of what it should:
string(4) "Live"
Options for MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER is "Live" and "Sandbox".
After removing and adding MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER a few times without any changes I completely removed the paypal script from the site and installet it again. now it works!
The following code works as expected:
<?php
define("MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER", "LIVE");
echo MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER ;
if (MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == "Live")
{
$form_action_url = 'https://www.paypal.com/cgi-bin/webscr';
}
else
{
$form_action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
}
echo ' '.$form_action_url;
die();
?>
// Outpu: Live https://www.paypal.com/cgi-bin/webscr
How exactly are you definine your constant?
When the following is changed:
define("MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER", "LIVE");
the output is
LIVE https://www.sandbox.paypal.com/cgi-bin/webscr
Edit: Based on your comment, the code is working exactly as it should then. You are defining your constant as LIVE
but then checking it in your if statement against Live
. When you compare them, they are not equal, therefore the if
statement evaluates to false and your second condition is executed.
<?php
if(!defined('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER')) {
define('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER', 'Live');
}
if(MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == 'Live') {
echo('live');
} else {
echo('sandboxing');
}
?>
Shows live ;-))
Works as expected - can NOT reproduce your described result.