Skip to content

Conversation

@MarijusDilys
Copy link
Contributor

Self-Checks

  • I have performed a self-review of my code.
  • I have updated/added necessary technical documentation in the README file.

JIRA task link

Summary

QA Checklist Labels

  • Bug fix?
  • New feature?
  • Improvement?
  • Technical debt?
  • Reusable?
  • Covered by tests?

QA Checklist

Additional Context

Frontend Changes

MarijusDilys and others added 30 commits October 16, 2025 09:09
…mprove performance

- Remove unused constant DISABLE_CACHE
- Remove unreachable return statement in hookActionEmailSendBefore
- Remove unused variable $activePaymentMethods in hookPaymentOptions
- Remove redundant validation check in hookActionObjectOrderPaymentAddAfter
- Add service container caching to prevent re-instantiation
- Extract services from loop in hookPaymentOptions for better performance
- Simplify install method by removing unnecessary intermediate variables
- Improve variable naming clarity ($isCreditCardSavingEnabledForUser)
- Add proper PHPDoc for getService method
- Add return types to VersionUtility methods (all return bool or string)
- Add return type to PriceUtility::convertToCents (returns int)
- Add return types to SaferPayExceptionService methods
- Add return type to SaferPayCartService::isCurrencyAvailable (returns bool)
- Add return types to LegacyTranslator methods
- Add return types to PaymentRestrictionValidation interface and implementations
- Add PHPDoc annotations to SaferPayOrderRepository methods
- Add PHPDoc property annotations to SaferPayObtainPaymentMethods

Improves type safety and IDE autocomplete support throughout the module.
git pu
- Add return type hint ?: Cart to LegacyContext::getCart()
- Add return type hints ?object to all API request service methods
- Add return type hint AssertBody to AuthorizationService::createObjectsFromAuthorizationResponse()
- Fix PHPDoc for ApiRequest::get() to correctly indicate object|null instead of array|null

All changes follow Gemini code review suggestions from PR #300
- Move configuration restoration to finally blocks to guarantee execution even when exceptions occur
- Update validateTerminalId to use credentials from form input instead of saved configuration
- Simplify terminal data parsing by removing redundant object format checks
- Remove HOW_TEST.md documentation file

These changes fix critical issues identified in code review where configuration state could become inconsistent during API calls.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Set proper permissions for saferpayofficial module:
- Directories: 755 (rwxr-xr-x)
- Files: 644 (rw-r--r--)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
SL-331 remove JS library from UI & permissions fix
MarijusDilys and others added 12 commits November 20, 2025 13:02
- Add proper error logging using SaferPay LoggerInterface in validateTerminalId() and getTerminalsForEnvironment()
- Optimize validateTerminalId() to fetch terminals only once instead of making two separate API calls
- Replace empty catch blocks with proper error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Enhanced type safety across multiple classes by adding missing parameter and return type hints as identified in Gemini code review. This improves code quality and catches potential type-related bugs at compile time.

Changes:
- SaferPayOrderRepository: Added int parameter types and SaferPayOrder/array return types
- SaferPayOrderBuilder: Added object parameter types for body parameters
- PaymentTypeProvider: Added string parameter types to all methods
- LegacyTranslator: Added string parameter type to translate method

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add type hints to TranslatorInterface::translate() to match LegacyTranslator implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
The object type hint was introduced in PHP 7.2.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Set platform PHP version to 7.1
- Add PHP >=7.1 requirement
- Pin dev dependencies to PHP 7.1 compatible versions

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pin php-cs-fixer to ^2.16.7 and add symfony/process ^3.4 constraint.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Advisory PKSA-wws7-mr54-jsny affects symfony/process but newer versions
require PHP 7.2.5+, which is incompatible with our PHP 7.1 requirement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MarijusDilys, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request prepares for release 2.0.3 by upgrading the module's PHP compatibility, enhancing the administrative experience with dynamic terminal management, and boosting application responsiveness through targeted database indexing. It also includes a comprehensive code quality pass to improve the codebase's robustness and clarity.

Highlights

  • PHP Version Update: The minimum required PHP version has been updated from 5.6 to 7.1 in composer.json, aligning the project with more modern PHP standards and features.
  • Dynamic Terminal Selection: The admin settings now feature dynamic terminal selection, allowing administrators to choose from available SaferPay terminals directly within the configuration interface. This includes validation to ensure the selected terminal ID is correct.
  • Database Performance Optimization: Several new indexes have been added to key database tables (saferpay_order, saferpay_assert, saferpay_card_alias, saferpay_order_refund) to significantly improve query performance and overall database efficiency.
  • Admin Settings Streamlining: Unnecessary input fields related to the JavaScript library URL have been removed from the admin settings, simplifying the configuration process.
  • Code Quality Improvements: Extensive refactoring has been performed across various files, including the addition of return type hints and docblocks to numerous methods, enhancing code readability, maintainability, and static analysis capabilities.
Ignored Files
  • Ignored by pattern: .github/workflows/** (6)
    • .github/workflows/PS1764_Cypress_Browserstack.yml
    • .github/workflows/PS1770_Cypress_Browserstack.yml
    • .github/workflows/PS1784_Cypress_Browserstack.yml
    • .github/workflows/PS1786_Cypress_Browserstack.yml
    • .github/workflows/deploy.yml
    • .github/workflows/release.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable improvements for the 2.0.3 release, including database performance optimizations through new indexes, dynamic terminal selection, and significant code quality enhancements with the addition of type hinting across many files. The refactoring to improve performance in saferpayofficial.php is also a welcome change.

However, there are a few critical issues that need to be addressed. A security vulnerability is being ignored in composer.json, which poses a significant risk. More importantly, the upgrade script for version 2.0.2 has been incorrectly overwritten with changes for 2.0.3, which could cause serious problems for users upgrading the module. I've also noted some minor issues, such as typos in the changelog and opportunities to improve SQL query formatting.

Comment on lines +28 to 130
function upgrade_module_2_0_2(SaferPayOfficial $module)
{
Configuration::updateValue('SAFERPAY_SEND_ORDER_CONF_MAIL', 0);
Configuration::updateValue('SAFERPAY_GROUP_CARDS', 0);
$db = Db::getInstance();
$success = true;

return true;
// Add indexes for saferpay_order table
$orderIndexes = [
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order` ADD INDEX `idx_id_order` (`id_order`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order` ADD INDEX `idx_id_cart` (`id_cart`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order` ADD INDEX `idx_id_customer` (`id_customer`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order` ADD INDEX `idx_transaction_id` (`transaction_id`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order` ADD INDEX `idx_status_flags` (`authorized`, `captured`, `pending`)",
];

foreach ($orderIndexes as $indexSql) {
try {
$result = $db->execute($indexSql);
if (!$result) {
$error = $db->getMsgError();
if (strpos($error, 'Duplicate key name') === false) {
$success = false;
PrestaShopLogger::addLog('SaferPay: Failed to add order index - ' . $error, 3, null, 'SaferPayOrder');
}
}
} catch (Exception $e) {
PrestaShopLogger::addLog('SaferPay: Order index creation skipped - ' . $e->getMessage(), 1, null, 'SaferPayOrder');
}
}

// Add indexes for saferpay_card_alias table
$cardAliasIndexes = [
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_card_alias` ADD INDEX `idx_id_customer` (`id_customer`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_card_alias` ADD INDEX `idx_payment_method` (`payment_method`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_card_alias` ADD INDEX `idx_customer_payment` (`id_customer`, `payment_method`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_card_alias` ADD INDEX `idx_valid_till` (`valid_till`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_card_alias` ADD INDEX `idx_alias_id` (`alias_id`)",
];

foreach ($cardAliasIndexes as $indexSql) {
try {
$result = $db->execute($indexSql);
if (!$result) {
$error = $db->getMsgError();
if (strpos($error, 'Duplicate key name') === false) {
$success = false;
PrestaShopLogger::addLog('SaferPay: Failed to add card alias index - ' . $error, 3, null, 'SaferPayCardAlias');
}
}
} catch (Exception $e) {
PrestaShopLogger::addLog('SaferPay: Card alias index creation skipped - ' . $e->getMessage(), 1, null, 'SaferPayCardAlias');
}
}

// Add indexes for saferpay_assert table
$assertIndexes = [
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_assert` ADD INDEX `idx_id_saferpay_order` (`id_saferpay_order`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_assert` ADD INDEX `idx_payment_method` (`payment_method`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_assert` ADD INDEX `idx_brand` (`brand`)",
];

foreach ($assertIndexes as $indexSql) {
try {
$result = $db->execute($indexSql);
if (!$result) {
$error = $db->getMsgError();
if (strpos($error, 'Duplicate key name') === false) {
$success = false;
PrestaShopLogger::addLog('SaferPay: Failed to add assert index - ' . $error, 3, null, 'SaferPayAssert');
}
}
} catch (Exception $e) {
PrestaShopLogger::addLog('SaferPay: Assert index creation skipped - ' . $e->getMessage(), 1, null, 'SaferPayAssert');
}
}

// Add indexes for saferpay_order_refund table
$refundIndexes = [
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order_refund` ADD INDEX `idx_id_saferpay_order` (`id_saferpay_order`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order_refund` ADD INDEX `idx_id_order` (`id_order`)",
"ALTER TABLE `" . _DB_PREFIX_ . "saferpay_order_refund` ADD INDEX `idx_transaction_id` (`transaction_id`)",
];

foreach ($refundIndexes as $indexSql) {
try {
$result = $db->execute($indexSql);
if (!$result) {
$error = $db->getMsgError();
if (strpos($error, 'Duplicate key name') === false) {
$success = false;
PrestaShopLogger::addLog('SaferPay: Failed to add refund index - ' . $error, 3, null, 'SaferPayOrderRefund');
}
}
} catch (Exception $e) {
PrestaShopLogger::addLog('SaferPay: Refund index creation skipped - ' . $e->getMessage(), 1, null, 'SaferPayOrderRefund');
}
}

if ($success) {
PrestaShopLogger::addLog('SaferPay: Database indexes added successfully', 1, null, 'SaferPayOptimization');
}

return $success;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change overwrites the upgrade script for version 2.0.2 with logic intended for 2.0.3 (database index optimization). This is a critical issue as it will prevent users upgrading from versions prior to 2.0.2 from receiving the correct updates for that version, and could cause issues if they try to upgrade again.

A new upgrade script, upgrade/install-2.0.3.php, should be created with a corresponding upgrade_module_2_0_3() function for these changes. The upgrade/install-2.0.2.php file should be reverted to its original state.

Comment on lines +23 to 25
"audit": {
"ignore": ["PKSA-wws7-mr54-jsny"]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Ignoring the security audit for PKSA-wws7-mr54-jsny is a security risk. This vulnerability in vlucas/phpdotenv versions before 5.0.0 can lead to the exposure of your .env file if the document root is misconfigured. It is highly recommended to update vlucas/phpdotenv to a secure version (e.g., ^5.0) instead of ignoring the audit.

changelog.md Outdated
Comment on lines 203 to 204
- Dynamic termimal selection
- Removed uneccesary inputs from admin settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a couple of typos in the changelog entry for version 2.0.3.

  • termimal should be terminal.
  • uneccesary should be unnecessary.
Suggested change
- Dynamic termimal selection
- Removed uneccesary inputs from admin settings
- Dynamic terminal selection
- Removed unnecessary inputs from admin settings

Comment on lines +258 to +268
// Services used in the loop - initialized once for performance
/** @var SaferPayCardAliasRepository $cardAliasRepository */
$cardAliasRepository = $this->getService(SaferPayCardAliasRepository::class);
/** @var PaymentRedirectionProvider $paymentRedirectionProvider */
$paymentRedirectionProvider = $this->getService(PaymentRedirectionProvider::class);
/** @var LegacyTranslator $translator */
$translator = $this->getService(LegacyTranslator::class);

$isBusinessLicenseEnabled = Configuration::get(SaferPayConfig::BUSINESS_LICENSE . SaferPayConfig::getConfigSuffix());
$isCreditCardSavingEnabled = Configuration::get(SaferPayConfig::CREDIT_CARD_SAVE);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Moving the service and configuration lookups out of the foreach loop is a great performance improvement. This avoids redundant calls on each iteration.

MarijusDilys and others added 12 commits November 21, 2025 16:14
Introduced interface for request DTOs to improve code consistency and
maintainability. Converted remaining TODO comments to documentation notes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Added return type hints and parameter type hints to SaferPayOrderStatusService
and RequestObjectCreator for improved code quality and IDE support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This reverts commit c084aec.
Replaced abandoned container-interop/container-interop with psr/container
by upgrading league/container from 2.5.0 to ^3.0 (PHP 7.1 compatible).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Upgrade league/container to 3.x to remove abandoned dependency
- Add missing Smarty variables before rendering payment_method_all.tpl
- Add error message when no payment methods are available
…ions-payment-all

BUGFIX /fix undefined country options payment all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants