Jump to content

PrestaShop Addons Validator – inconsistent behavior with _PS_VERSION_ and enums in PS 9 payment module


wuj3k

Recommended Posts

I'm developing a payment module for PrestaShop 9, fully following the official documentation:
https://devdocs.prestashop-project.org/9/modules/payment/

The module is written for PHP 8.1+ and uses native PHP enums.
In the main module class, I set:
 

$this->ps_versions_compliancy = ['min' => '9.0.0', 'max' => _PS_VERSION_];

When validating the module with the PrestaShop Addons Validator I get the following error:

Method 'MyModule\Module\Enums\ErrorPage::tryFrom()' does not exists

The tryFrom() method is native to PHP 8.1 enums, and the module works perfectly in PrestaShop 9.

Unexpected behavior

If I change the line to:
 

$this->ps_versions_compliancy = ['min' => '9.0.0', 'max' => '9.9.9'];

the enum error disappears — the validator correctly accepts PHP enums —
but a new, unrelated error appears:

Mandatory use of 'PrestaShop\PrestaShop\Core\Payment\PaymentOption' not found in module, but required for payment modules from PS 1.7.

However, my module meets all the requirements from the official PS9 payment module documentation:

1) The main class extends PaymentModule.

2) It implements both hookPaymentOptions() and hookPaymentReturn() and properly registers the PaymentOptions and PaymentReturn hooks.

3) It doesn’t include a submit button in the HTML.

4) In the hookPaymentOptions() method, it returns an array of PaymentOption.

5) The file includes the correct namespace import:
 

use PrestaShop\PrestaShop\Core\Payment\PaymentOption;

So the validator should recognize the class and not report this as missing.

Question

Is this a known issue with the Addons Validator when checking PS 9 payment modules?
Are there any updated guidelines for how to define ps_versions_compliancy for modules targeting PS 9 exclusively, so that enums and validator checks both work correctly?

Thanks in advance!

Link to comment
Share on other sites

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...