[ECP-9686] Implement clean-up additional_information functionality#2981
[ECP-9686] Implement clean-up additional_information functionality#2981candemiralp merged 20 commits intodevelop-10from
Conversation
There was a problem hiding this comment.
Hello @candemiralp, 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!
Summary of Changes
Hello team, gemini-code-assist here with a summary of this pull request by @candemiralp.
The main goal of this PR is to clean up temporary data stored in the additional_information field of the Magento Order Payment object. Specifically, it targets the action and additionalData fields, which are often populated during the payment process and webhook handling but may not need to persist long-term.
To achieve this, a new service (CleanupAdditionalInformation) is introduced, implementing a new interface (CleanupAdditionalInformationInterface). This service is then integrated into the AuthorisationWebhookHandler. After an authorisation webhook is processed, whether successfully or not, the new cleanup service is called to remove the specified fields from the payment's additional_information. This helps keep the payment data cleaner and potentially reduces storage overhead or complexity when accessing this field later.
Highlights
- New Cleanup Service: Introduces a new service (
Adyen\Payment\Model\CleanupAdditionalInformation) and its interface (Adyen\Payment\Api\CleanupAdditionalInformationInterface) dedicated to cleaning up specific fields within theadditional_informationof an order payment. - Webhook Integration: Integrates the new cleanup service into the
AuthorisationWebhookHandler. The cleanup process is triggered after both successful and failed authorisation webhook processing. - Targeted Fields: Defines and targets specific fields (
actionandadditionalData) within theadditional_informationarray for removal. - Unit Tests: Adds a unit test for the new
CleanupAdditionalInformationmodel to ensure it correctly removes the specified fields.
Changelog
Click here to see the changelog
- Api/CleanupAdditionalInformationInterface.php
- Added new interface
CleanupAdditionalInformationInterface. - Defined constants
FIELD_ACTION,FIELD_ADDITIONAL_DATA, andFIELDS_TO_BE_CLEANED_UP. - Declared the
executemethod for cleaning the payment object.
- Added new interface
- Helper/Webhook/AuthorisationWebhookHandler.php
- Added dependency injection for
CleanupAdditionalInformationInterface. - Called the cleanup service's
executemethod after handling successful authorisations. - Called the cleanup service's
executemethod after handling failed authorisations.
- Added dependency injection for
- Model/CleanupAdditionalInformation.php
- Added new model
CleanupAdditionalInformationimplementing the cleanup interface. - Implemented the
executemethod to iterate through defined fields and remove them fromadditional_information.
- Added new model
- Test/Unit/Model/CleanupAdditionalInformationTest.php
- Added a new unit test class
CleanupAdditionalInformationTest. - Tested the
executemethod to verify thatunsAdditionalInformationis called for the expected fields.
- Added a new unit test class
- etc/di.xml
- Added a preference binding
Adyen\Payment\Api\CleanupAdditionalInformationInterfacetoAdyen\Payment\Model\CleanupAdditionalInformation.
- Added a preference binding
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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.
Data fields grow wide,
Webhook fires, cleanup waits,
Less is sometimes more.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a new class to clean up specific fields from the additional_information attribute of the order payment object after authorization webhooks are processed. This is a good practice for data hygiene and potentially for reducing stored data.
The changes are well-structured, with a clear interface, a straightforward implementation, and a corresponding unit test. The integration into the AuthorisationWebhookHandler for both successful and failed authorisations is logical. The code adheres to modern PHP practices and Magento conventions, including the use of dependency injection and PHPDocs.
Overall, the code quality is high, and the changes are clear and maintainable. Well done!
Summary of Findings
- Copyright Year: The copyright year in the newly added files (
Api/CleanupAdditionalInformationInterface.php,Model/CleanupAdditionalInformation.php,Test/Unit/Model/CleanupAdditionalInformationTest.php) is set to 2025. While this is a common practice to preemptively set it for new files, it's technically in the future. This is a minor, stylistic observation and does not affect functionality. (Severity: low, not commented due to review settings). - Unit Test Assertion Specificity: In
Test/Unit/Model/CleanupAdditionalInformationTest.php, thetestExecutemethod useswillReturnMapto verify calls tounsAdditionalInformation. The order of field names in theFIELDS_TO_BE_CLEANED_UPconstant isFIELD_ACTIONthenFIELD_ADDITIONAL_DATA. ThewillReturnMapin the test hasFIELD_ADDITIONAL_DATAlisted beforeFIELD_ACTION. WhilewillReturnMapprimarily maps arguments to return values and the current test correctly verifies that both fields are processed, usingwithConsecutivewould be a more precise way to assert the arguments if the order of calls was critical. However, for this specific cleanup logic, the order of unsetting these two fields is unlikely to matter, making the current test acceptable. (Severity: low, not commented due to review settings).
Merge Readiness
The pull request is well-implemented and addresses the stated objective effectively. The code is clean, tested, and follows good practices. I found no critical, high, or medium severity issues. Based on this review, the PR appears to be in good shape for merging. As an AI reviewer, I am not authorized to approve pull requests; please ensure it undergoes any further required human review and approval processes.
|



Description
This PR implements a new functionality to clean-up the data temporarily stored in
additional_informationfield of Magento's Order Payment object. This class is triggered after completing the authorisation webhook processing.Tested scenarios