Forums / PayPal Website Payments Pro support / PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

Views: 5,974

Results 1 to 12 of 12
18 Jan 2024, 4:15 AM
#1
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

Zencart 1.5.8a - PHP 8.2 - No Plugins - Fresh install w/upgraded DB

Hello, I am getting this error with a fresh install and upgraded database.

PHP Fatal error: Uncaught Error: Undefined constant "MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY"

/home/dev/public_html/includes/modules/payment/paypaldp.php:264

Because of the error the payment modules page only loads halfway, stops right after Paypal Payments Standard. It also affects the orders-edit page with just a white screen.

Any seen this before?

Thanks

18 Jan 2024, 10:23 AM
#2
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,305
Plugin Contributions:
39

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

djdavedawson:

Zencart 1.5.8a - PHP 8.2 - No Plugins - Fresh install w/upgraded DB

Hello, I am getting this error with a fresh install and upgraded database.

PHP Fatal error: Uncaught Error: Undefined constant "MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY"

/home/dev/public_html/includes/modules/payment/paypaldp.php:264

> 
> Because of the error the payment modules page only loads halfway, stops right after Paypal Payments Standard. It also affects the orders-edit page with just a white screen. 
> 
> Any seen this before?
> 
> Thanks

Have you set your country in 

Configuration >> My Store > Country


~Melanie
18 Jan 2024, 10:27 AM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

Go to Admin > Modules > Payment and click on the PayPal you have installed. This will fix your installation.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 Jan 2024, 10:48 AM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

swguy:

Go to Admin > Modules > Payment and click on the PayPal you have installed. This will fix your installation.
Unfortunately, it won't. Apparently the previous database has paypaldp enabled, but that version didn't have the MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY setting defined.

That setting's added in the module's *check *method, but the processing doesn't get that far due to the PHP Fatal error due to the constant not being defined.

Noting that another issue is that the setting is either USA, UK or Canada, but various comparisons in the module check for US instead of USA.

18 Jan 2024, 10:53 AM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

So uninstall/reinstall?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 Jan 2024, 11:05 AM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

swguy:

So uninstall/reinstall?
And lose all the configuration setting from the previous install (that you can't view due to that fatal error)?

18 Jan 2024, 11:16 AM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

lat9:

Unfortunately, it won't. Apparently the previous database has paypaldp enabled, but that version didn't have the MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY setting defined.

That setting's added in the module's *check *method, but the processing doesn't get that far due to the PHP Fatal error due to the constant not being defined.

Noting that another issue is that the setting is either USA, UK or Canada, but various comparisons in the module check for US instead of USA.
Should line 264

        if ( ((MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'US' || MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'Canada') && (MODULE_PAYMENT_PAYPALWPP_APISIGNATURE == '' || MODULE_PAYMENT_PAYPALWPP_APIUSERNAME == '' || MODULE_PAYMENT_PAYPALWPP_APIPASSWORD == ''))

be

        if ( ((MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == '[B]UK[/B]' || MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'Canada') && (MODULE_PAYMENT_PAYPALWPP_APISIGNATURE == '' || MODULE_PAYMENT_PAYPALWPP_APIUSERNAME == '' || MODULE_PAYMENT_PAYPALWPP_APIPASSWORD == ''))
18 Jan 2024, 1:39 PM
#8
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

Ok so I tried updating line 264 like this.

if ( ((MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'USA' || MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'Canada') && (MODULE_PAYMENT_PAYPALWPP_APISIGNATURE == '' || MODULE_PAYMENT_PAYPALWPP_APIUSERNAME == '' || MODULE_PAYMENT_PAYPALWPP_APIPASSWORD == ''))

Unfortunately, this did not work for my case.

However, I added this right above line 264

define('MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY','US');

This allowed the payment module page to load completely. Once loaded I

*Took screen-shots of all the settings.
*Clicked Remove Module
*Clicked Install Module
*Entered my settings
*Then removed my define

define('MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY','US');

This process added the correct entries to the db.

So far everything seems to be loading correctly.

18 Jan 2024, 2:33 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

Smart! That was an excellent way to work-around the issue! **Don't forget to remove that define statement now that the configuration setting is (er) set.

**Note to self, read the whole post before you reply!

18 Jan 2024, 7:56 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

The patch which is going into v2.0.0, and can safely be applied to v1.5.8 is: https://github.com/zencart/zencart/pull/6144/files

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Mar 2024, 4:24 PM
#11
rkhan3366 avatar

rkhan3366

New Zenner

Join Date:
May 2020
Location:
Dallas, Texas
Posts:
14
Plugin Contributions:
0

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

I had to add this define statement at the top of the page to make it work.

22 Apr 2024, 1:30 AM
#12
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: PHP Fatal error: Undefined constant MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY

This is still an issue in 2.0.

[21-Apr-2024 21:24:22 America/New_York] Request URI: /admin/index.php?cmd=modules&set=payment, IP address: 111.111.111.111
--> PHP Fatal error: Uncaught Error: Undefined constant "MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY" in public_html/includes/modules/payment/paypaldp.php:292
Stack trace:
#0 public_html/admin/modules.php(173): paypaldp->__construct()
#1 public_html/admin/index.php(11): require('...')
#2 {main}
  thrown in public_html/includes/modules/payment/paypaldp.php on line 292.

[21-Apr-2024 21:24:22 America/New_York] Request URI: /admin/index.php?cmd=modules&set=payment, IP address: 111.111.111.111
--> PHP Fatal error: Uncaught Error: Undefined constant "MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY" in public_html/includes/modules/payment/paypaldp.php:292
Stack trace:
#0 public_html/admin/modules.php(173): paypaldp->__construct()
#1 public_html/admin/index.php(11): require('...')
#2 {main}
  thrown in public_html/includes/modules/payment/paypaldp.php on line 292.