[ECP-9847] Improve authorized amount comparison#3261
[ECP-9847] Improve authorized amount comparison#3261candemiralp wants to merge 12 commits intodevelop-11from
Conversation
Summary of ChangesHello, 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 authorization process within the Adyen module. It introduces a new Highlights
🧠 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. Changelog
Ignored Files
Activity
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 a significant and beneficial refactoring by centralizing authorization logic into a new AuthorizationHandler class and adding an observer to handle authorization immediately after order placement. This improves the architecture by enhancing separation of concerns and simplifying webhook handlers. However, I've identified a critical issue in a new test file that will cause a fatal error, a potential regression concerning Boleto payment status handling, and a minor bug in the new observer that could lead to warnings.
| $this->authorizationHandler = new AuthorizationHandler( | ||
| $this->adyenOrderPaymentHelperMock, | ||
| $this->caseManagementHelperMock, | ||
| $this->invoiceHelperMock, | ||
| $this->paymentMethodsHelperMock, | ||
| $this->orderHelperMock, | ||
| $this->adyenLoggerMock | ||
| ); |
There was a problem hiding this comment.
The constructor for AuthorizationHandler is being called with 6 arguments, but it expects 7. The $dataHelper dependency is missing. This will cause a fatal error when running the tests.
Please also add a mock for \Adyen\Payment\Helper\Data and pass it to the constructor.
$dataHelperMock = $this->createMock(\Adyen\Payment\Helper\Data::class);
$this->authorizationHandler = new AuthorizationHandler(
$this->adyenOrderPaymentHelperMock,
$this->caseManagementHelperMock,
$this->invoiceHelperMock,
$this->paymentMethodsHelperMock,
$this->orderHelperMock,
$this->adyenLoggerMock,
$dataHelperMock
);| $status = $this->getVirtualStatus($order, $status); | ||
| } | ||
|
|
||
| // check for boleto if payment is totally paid | ||
| if ($order->getPayment()->getMethod() == "adyen_boleto") { | ||
| $status = $this->paymentMethodsHelper->getBoletoStatus($order, $notification, $status); | ||
| } |
There was a problem hiding this comment.
The logic for handling Boleto payment statuses, specifically for overpayment and underpayment, has been removed. This was handled by the getBoletoStatus method, which has also been removed from PaymentMethods helper. This appears to be a regression as there is no replacement logic. Was the removal of this functionality intentional?
| $order = $this->authorizationHandler->execute( | ||
| $order, | ||
| $response['paymentMethod']['brand'], | ||
| $response['pspReference'], | ||
| $response['amount']['value'], | ||
| $response['amount']['currency'], | ||
| $response['additionalData'] | ||
| ); |
There was a problem hiding this comment.
The $response['additionalData'] key may not exist in the payment response, which would cause a warning. It's safer to use the null coalescing operator to provide an empty array as a default.
$order = $this->authorizationHandler->execute(
$order,
$response['paymentMethod']['brand'],
$response['pspReference'],
$response['amount']['value'],
$response['amount']['currency'],
$response['additionalData'] ?? []
);
Description
Tested scenarios
Fixes