Skip to content

[ECP-9686] Implement clean-up additional_information functionality#2981

Merged
candemiralp merged 20 commits intodevelop-10from
ECP-9686
Jun 16, 2025
Merged

[ECP-9686] Implement clean-up additional_information functionality#2981
candemiralp merged 20 commits intodevelop-10from
ECP-9686

Conversation

@candemiralp
Copy link
Contributor

Description

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

Tested scenarios

  • Webhook processing
  • Voucher payment information block

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.

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 the additional_information of 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 (action and additionalData) within the additional_information array for removal.
  • Unit Tests: Adds a unit test for the new CleanupAdditionalInformation model 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, and FIELDS_TO_BE_CLEANED_UP.
    • Declared the execute method for cleaning the payment object.
  • Helper/Webhook/AuthorisationWebhookHandler.php
    • Added dependency injection for CleanupAdditionalInformationInterface.
    • Called the cleanup service's execute method after handling successful authorisations.
    • Called the cleanup service's execute method after handling failed authorisations.
  • Model/CleanupAdditionalInformation.php
    • Added new model CleanupAdditionalInformation implementing the cleanup interface.
    • Implemented the execute method to iterate through defined fields and remove them from additional_information.
  • Test/Unit/Model/CleanupAdditionalInformationTest.php
    • Added a new unit test class CleanupAdditionalInformationTest.
    • Tested the execute method to verify that unsAdditionalInformation is called for the expected fields.
  • etc/di.xml
    • Added a preference binding Adyen\Payment\Api\CleanupAdditionalInformationInterface to Adyen\Payment\Model\CleanupAdditionalInformation.
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

  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.

@candemiralp candemiralp changed the title [ECP-9686] Create a class to clean-up additional information [ECP-9686] Implement clean-up additional_information functionality Jun 5, 2025
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 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, the testExecute method uses willReturnMap to verify calls to unsAdditionalInformation. The order of field names in the FIELDS_TO_BE_CLEANED_UP constant is FIELD_ACTION then FIELD_ADDITIONAL_DATA. The willReturnMap in the test has FIELD_ADDITIONAL_DATA listed before FIELD_ACTION. While willReturnMap primarily maps arguments to return values and the current test correctly verifies that both fields are processed, using withConsecutive would 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.

@sonarqubecloud
Copy link

@candemiralp candemiralp merged commit 9236fd9 into develop-10 Jun 16, 2025
14 of 15 checks passed
@candemiralp candemiralp deleted the ECP-9686 branch June 16, 2025 07:32
@khushboo-singhvi khushboo-singhvi added the Breaking change Indicates a change that has caused a major version update label Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking change Indicates a change that has caused a major version update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants