Repository navigation
fix: third parties checkout - #31
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📝 WalkthroughWalkthroughThe update migrates the order validation hook from Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
actionValidateOrdertoactionValidateOrderBeforehook 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 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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 | 🟡 MinorSanitize
kyc_requiredbefore casting to bool.
Tools::getValuereturns 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).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Linked issue
Closes #[issue-number]
Type of change
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
actionValidateOrderBeforehook 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
actionValidateOrdertoactionValidateOrderBeforefor better compatibility with PrestaShop 8 and 9, including an override ofPaymentModule::validateOrderto inject the hook for PrestaShop 8. (pskyc.php,override/classes/PaymentModule.php,INTEGRATION.md,CHANGELOG.md) [1] [2] [3] [4] [5] [6]pskyc.php)User Experience Improvements
pskyc.php,controllers/front/verify.php) [1] [2] [3]views/templates/front/account/page.tpl,translations/fr-FR/ModulesPskycShop.fr-FR.xlf) [1] [2] [3]Documentation and Configuration
INTEGRATION.md,CHANGELOG.md) [1] [2]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
Summary by CodeRabbit
New Features
Improvements
Localization
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.