Skip to content

fix: third parties checkout - #31

Merged
vachmara merged 9 commits into
devfrom
fix/third-parties-checkout
Feb 1, 2026
Merged

vachmara merged 9 commits into
devfrom
fix/third-parties-checkout

Conversation

@vachmara

@vachmara vachmara commented Feb 1, 2026 •

Copy link
Copy Markdown
Owner

Linked issue

Closes #[issue-number]

Type of change

  • Bug fix
  • New feature
  • Enhancement
  • Documentation update
  • Other (please describe):

Description

This pull request introduces significant improvements to the KYC (Know Your Customer) verification flow, focusing on compatibility with PrestaShop 8 and 9, better user experience during order validation, and enhanced feedback for customers. The most important changes include migrating to the actionValidateOrderBefore hook for order validation, implementing clean redirects to the KYC verification page, providing contextual alerts with translation support, and updating documentation and configuration displays.

Order Validation and Hook Handling

  • Migrated order validation logic from actionValidateOrder to actionValidateOrderBefore for better compatibility with PrestaShop 8 and 9, including an override of PaymentModule::validateOrder to inject the hook for PrestaShop 8. (pskyc.php, override/classes/PaymentModule.php, INTEGRATION.md, CHANGELOG.md) [1] [2] [3] [4] [5] [6]
  • Updated the hook handler to use the new hook and improved parameter handling, ensuring robust blocking of orders when KYC is required but not approved. (pskyc.php)

User Experience Improvements

  • Replaced exception throwing with a clean redirect to the KYC verification page if verification is required, passing a URL parameter to trigger contextual alerts. (pskyc.php, controllers/front/verify.php) [1] [2] [3]
  • Added a contextual alert on the KYC verification page to inform users when their order requires identity verification, with support for French translation. (views/templates/front/account/page.tpl, translations/fr-FR/ModulesPskycShop.fr-FR.xlf) [1] [2] [3]

Documentation and Configuration

  • Updated integration documentation and changelog to reflect new hook usage, improved compatibility notes, and added a summary of recent changes. (INTEGRATION.md, CHANGELOG.md) [1] [2]
  • Displayed the module version dynamically in the admin configuration panel for better maintainability. (pskyc.php, views/templates/admin/configure.tpl) [1] [2]

These changes collectively enhance the reliability and usability of the KYC module, especially in multi-version PrestaShop environments, while providing clearer feedback and guidance to both customers and integrators.

How to test

Already tested

Checklist

  • I have read the CONTRIBUTING guidelines.
  • Lint and tests pass locally.
  • I have updated documentation where relevant.
  • I have added tests where possible.
  • The code is in English and follows PrestaShop module conventions.

Summary by CodeRabbit

  • New Features

    • Contextual alerts with URL parameters for clearer user guidance during identity verification
  • Improvements

    • Seamless redirects to KYC verification page instead of error messages
    • Enhanced compatibility with PrestaShop 8 and 9
  • Localization

    • French translations for verification alert messages
  • Documentation

    • Updated integration documentation with current specifications

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@vachmara has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The update migrates the order validation hook from actionValidateOrder to actionValidateOrderBefore, implementing clean redirects to KYC verification instead of exception blocking. A new PaymentModule override conditionally executes the new hook for PrestaShop versions before 9.0.0. French translations, template variables, and dynamic version display are added.

Changes

Cohort / File(s) Summary
Hook & Validation Logic
override/classes/PaymentModule.php, pskyc.php
New PaymentModule override with validateOrder method that conditionally fires actionValidateOrderBefore hook for PS < 9.0.0. Main module hook renamed from hookActionValidateOrder to hookActionValidateOrderBefore; validation now redirects to verification page instead of blocking with exceptions.
Documentation Updates
CHANGELOG.md, INTEGRATION.md
Updated CHANGELOG with version 1.1.3 entries documenting redirects, contextual alerts, and French translation. INTEGRATION.md updated to reflect hook name change, expanded parameters, and version bump to 1.1.3.
Frontend Templates & Controllers
views/templates/front/account/page.tpl, controllers/front/verify.php
Added conditional kyc_required_alert template variable and alert rendering for KYC verification prompts on the account page.
Admin Template
views/templates/admin/configure.tpl
Replaced hard-coded version "0.1.0" with dynamic module_version variable display.
Localization
translations/fr-FR/ModulesPskycShop.fr-FR.xlf
Added French translation for identity verification alert message.

Sequence Diagram

sequenceDiagram
    participant Client as Client Request
    participant Module as Pskyc Module
    participant Override as PaymentModule Override
    participant Hook as Hook System
    participant Core as PrestaShop Core
    participant Response as KYC Redirect

    Client->>Module: initiateOrder()
    Module->>Override: validateOrder(cart, state, amount, ...)
    Override->>Hook: Check PS version < 9.0.0
    alt PS < 9.0.0
        Hook->>Hook: Execute actionValidateOrderBefore
        Module->>Module: Check KYC required?
        alt KYC Required & Not Approved
            Module->>Response: Redirect to verification page
            Response-->>Client: kyc_required_alert=true
        else KYC Not Required / Already Approved
            Override->>Core: parent::validateOrder()
            Core-->>Override: Order created
        end
    else PS >= 9.0.0
        Override->>Core: parent::validateOrder()
        Core-->>Override: Order created
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hop through the hooks, we migrate with care,
From validation blocks to redirects so fair,
French translations bloom, alerts now so bright,
The KYC journey flows smooth as the night! 🌙✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: third parties checkout' is vague and doesn't clearly convey the main changes (KYC hook migration, redirects, PrestaShop 8/9 compatibility). Consider a more specific title like 'fix: migrate KYC validation to actionValidateOrderBefore for PS8/9 compatibility' to better describe the primary changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description comprehensively covers all required template sections and provides detailed explanations of the changes, rationale, and testing status.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/third-parties-checkout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses compatibility issues with third-party checkout modules by migrating from the actionValidateOrder hook to actionValidateOrderBefore hook. The changes improve the KYC verification flow by replacing exception-based blocking with clean redirects to the verification page, and add contextual alerts with translation support.

Changes:

  • Migrated order validation from actionValidateOrder to actionValidateOrderBefore hook with a PaymentModule override to inject the hook in PrestaShop 8
  • Replaced exception throwing with redirects to the KYC verification page with contextual alert parameters
  • Added French translations and dynamic version display in admin configuration

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pskyc.php Updated hook registration and handler to use actionValidateOrderBefore; added redirect logic instead of exceptions; added module version to template variables
override/classes/PaymentModule.php New override to inject actionValidateOrderBefore hook for PrestaShop 8 compatibility
controllers/front/verify.php Added kyc_required parameter handling for contextual alerts
views/templates/front/account/page.tpl Added conditional alert display when order requires KYC verification
views/templates/admin/configure.tpl Changed hardcoded version to dynamic module version variable
translations/fr-FR/ModulesPskycShop.fr-FR.xlf Added French translation for the KYC required alert message
tests/PsKyc/controllers/front/VerifyControllerFrontTest.php Added MIT license header
tests/PsKyc/controllers/front/CronControllerFrontTest.php Added MIT license header
tests/PsKyc/Mock/ModuleFrontController.php Added MIT license header
INTEGRATION.md Updated documentation to reflect new hook usage and updated dates
CHANGELOG.md Added entries documenting the new features and changes

Comment thread pskyc.php Resolved
Comment thread override/classes/PaymentModule.php Resolved
Comment thread override/classes/PaymentModule.php Resolved
Comment thread pskyc.php Resolved
Comment thread pskyc.php Resolved
Comment thread override/classes/PaymentModule.php Resolved
Comment thread override/classes/PaymentModule.php Resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
controllers/front/verify.php (1)

82-89: ⚠️ Potential issue | 🟡 Minor

Sanitize kyc_required before casting to bool.

Tools::getValue returns a string, and a direct bool cast treats values like "false" as truthy. To satisfy the input‑sanitization requirement for front controllers, restrict it to a strict 0/1 check.

Suggested fix
-            'kyc_required_alert' => (bool) Tools::getValue('kyc_required'),
+            'kyc_required_alert' => ((int) Tools::getValue('kyc_required')) === 1,
🤖 Fix all issues with AI agents
In `@INTEGRATION.md`:
- Around line 317-318: The compatibility note is inconsistent: the module class
(pskyc.php) declares support from PrestaShop 8.0.0 while INTEGRATION.md's tested
matrix lists only 8.1.x and 8.2.x; either run tests for 8.0.x and add 8.0.x to
INTEGRATION.md's tested versions, or update the module declaration in pskyc.php
to set the minimum supported version to 8.1.0 so docs and code match—pick one
approach, then update the corresponding place (INTEGRATION.md tested versions or
the version range in pskyc.php) and ensure the change is reflected in the module
metadata/version comment.

In `@override/classes/PaymentModule.php`:
- Around line 36-73: The validateOrder method's brace placement and indentation
within the Hook::exec block do not follow PSR-12; reformat the method signature
and body to use the opening brace on the next line for the method, align the
Hook::exec call and its associative array elements with 4-space indentation,
ensure the closing brace for the method sits alone on its own line, and maintain
consistent indentation for the parent::validateOrder(...) call; adjust the
validateOrder function, the Hook::exec(...) array, and the
parent::validateOrder(...) invocation accordingly.

In `@pskyc.php`:
- Around line 119-122: Update the PHPDoc for the hook handler tied to
'actionValidateOrderBefore' (the method handling the PaymentModule override) to
list all received parameters — ['cart', 'customer', 'currency',
'id_order_state', 'payment_method'] — as `@param` entries and add an explicit
`@return` annotation reflecting possible return types (void|bool or true|false) to
match the code paths; ensure the docblock sits directly above the method
handling that hook so tools and maintainers see the full signature and behavior
(also consider adding a short note about redirects not being honored for
AJAX/one-page checkout if you want to warn callers).

Comment thread INTEGRATION.md Resolved
Comment thread override/classes/PaymentModule.php Resolved
Comment thread pskyc.php Resolved
@vachmara
vachmara merged commit ba9c0ce into dev Feb 1, 2026
5 checks passed
@vachmara
vachmara deleted the fix/third-parties-checkout branch February 1, 2026 12:37
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