KNA-3366/feat: Basic tests and general order logic improvements#23
KNA-3366/feat: Basic tests and general order logic improvements#23
Conversation
Summary of ChangesHello @SalmanTwo, 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 significantly refactors the payment module's order processing to adopt a provider-first checkout flow, enhancing robustness and preventing issues like phantom orders. It introduces a new mechanism to track checkout attempts, ensuring idempotency and consistency by validating cart snapshots and using unique keys for order creation. The changes also include substantial improvements to tax calculation accuracy, error handling, and the addition of a dedicated test suite to ensure the reliability of critical payment logic. Highlights
Changelog
Ignored Files
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to the Two payment module, focusing on checkout flow robustness, security, and tax calculation accuracy. The major change is the move to a 'provider-first' checkout flow, where the PrestaShop order is created only after successful verification from the Two API. This eliminates issues with phantom orders on payment failure.
Key enhancements include:
- A new
twopayment_attempttable to track checkout attempts, enabling better idempotency and recovery. - Cart snapshot validation to prevent order creation if the cart changes after payment initiation.
- Use of an
X-Idempotency-Keyheader for order creation to prevent duplicate orders on retries. - Hardened tax calculation logic to ensure accuracy and API compliance.
- More robust error message parsing from the Two API.
- Improved session handling to prevent using stale company data across different countries.
- A comprehensive test suite has been added using PHPUnit and a standalone runner, which is a fantastic addition for maintainability.
The code is well-structured and the changes significantly improve the module's quality. I have one suggestion regarding the termination of non-AJAX requests in a controller for improved clarity and safety.
…back) across order payload lines
…lment transitions, and sync ES translations
No description provided.