Skip to content

[ECP-9847] Enhance the authorized amount comparison logic#3284

Merged
candemiralp merged 2 commits into
develop-11from
ECP-9847
Mar 27, 2026
Merged

[ECP-9847] Enhance the authorized amount comparison logic#3284
candemiralp merged 2 commits into
develop-11from
ECP-9847

Conversation

@candemiralp

@candemiralp candemiralp commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enhances how the plugin check the total authorized amount. The former approach had some issues when used together with DB replication. To overcome this challenge the order object is updated with the authorized amount and the comparison is made based on payment_authorization_amount field instead of adyen_order_payment table.

Tested scenarios

  • Card payments
  • Gift card payments

@candemiralp candemiralp requested a review from a team as a code owner March 26, 2026 13:43
@candemiralp candemiralp added the Breaking change Indicates a change that has caused a major version update label Mar 26, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the accuracy and efficiency of determining if an order's full amount has been authorized. By refactoring the comparison logic to directly use a stored authorization amount on the order and updating this amount via webhooks, the system can now more reliably handle different charged currencies (base vs. display). This change streamlines the authorization process and improves data consistency within the order object.

Highlights

  • Refactored Authorization Logic: The isFullAmountAuthorized method in AdyenOrderPayment was refactored to directly compare the order's grand total or base grand total with a new PaymentAuthorizationAmount property, based on the AdyenChargedCurrency. This replaces the previous logic of summing adyen_order_payment entries, leading to a more direct and efficient check.
  • New Charged Currency Constant: A new DISPLAY constant was introduced in ChargedCurrency to explicitly support authorization comparisons against the display currency, alongside the existing BASE currency.
  • Webhook Integration for Authorization Amount: The AuthorisationWebhookHandler was modified to update the order's PaymentAuthorizationAmount with the notification's amount during a successful authorization webhook. This ensures that the new authorization comparison logic has accurate and up-to-date data directly on the order object.
  • Unit Test Updates: Corresponding unit tests for AdyenOrderPaymentTest and AuthorisationWebhookHandlerTest were updated to reflect the changes in method signatures and logic, ensuring continued test coverage and correctness.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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.

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.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the isFullAmountAuthorized method in AdyenOrderPayment.php to use a match statement based on the charged currency (base or display), introducing a new DISPLAY constant in ChargedCurrency.php. It also updates the AuthorisationWebhookHandler.php to accumulate the PaymentAuthorizationAmount by adding the notification amount using a newly injected Data helper. The review comments highlight a critical issue regarding the direct comparison and arithmetic operations on floating-point numbers for financial amounts, which can lead to precision errors. It is recommended to perform these calculations using the smallest currency unit to ensure accuracy.

Comment thread Helper/AdyenOrderPayment.php
Comment thread Helper/Webhook/AuthorisationWebhookHandler.php
@sonarqubecloud

Copy link
Copy Markdown

@candemiralp candemiralp merged commit ecada7f into develop-11 Mar 27, 2026
9 of 10 checks passed
@candemiralp candemiralp deleted the ECP-9847 branch March 27, 2026 15:49
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.

3 participants