-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method Magento\Payment\Gateway\Data\Quote\QuoteAdapter::getGrandTotalAmount() always returns null #33872
Comments
Hi @oneserv-heuser. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
I can confirm this issue exists on a vanilla magento instance. |
For everyone interested here is a patch to fix this issue temporary:
Just copy it to a .patch file and follow instructions here: https://github.com/cweagans/composer-patches |
Hi @engcom-Delta. Thank you for working on this issue.
|
Hi @oneserv-heuser, Thanks for logging an issue. Kindly see if you can provide list of functional scenarios. Thanks |
@engcom-Delta Why should I provide functional scenarios? There is a obvious bug in the code base which also violates coding standards as in the interface OrderAdapterInterface (which the QuoteAdapter implements) the function getGrandTotalAmount() has the return type float. But in the QuoteAdapter it's implemented (hardcoded!) to return null which makes no sense at all as the required data can be obtained from the quote. Anyway, my use case is to use the Gateway Implementation for Payment methods which magento provides and requires me to use. Here is a code example: <?php
declare(strict_types=1);
namespace Oneserv\B2BInvoice\Gateway\Validator;
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
use Magento\Payment\Gateway\Validator\AbstractValidator;
/**
* Class AvailabilityValidator
*/
class AvailabilityValidator extends AbstractValidator
{
/**
* @param array{payment: PaymentDataObjectInterface} $validationSubject
* @return ResultInterface
*/
public function validate(array $validationSubject): ResultInterface
{
$order = $validationSubject['payment']->getOrder();
$grandTotal = (float)$order->getGrandTotalAmount();
if ($grandTotal === (float)0) {
return $this->createResult(false, [__('The order total amount must be greater than 0.')]);
}
return $this->createResult(true);
}
} In my code example you can see the use case. If the function getGrandTotalAmount() always returns null (which it does, as it's hardcoded to do that) my payment method will never be available. |
@engcom-Delta I've provided the requested information, can you please change the labels/ confirm that the issue exists? |
Hi @engcom-Lima. Thank you for working on this issue.
|
Hi @oneserv-heuser, I have gone through your comments and agrees that hardcoded null should not be there in getGrandTotalAmount() of class Thanks |
✅ Jira issue https://jira.corp.magento.com/browse/AC-1290 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Lima. Thank you for verifying the issue. |
Hi @oneserv-heuser, Before we move ahead with this issue confirmation, there is 1 more thing which we need to clarify: As per your use case, you are calling Thanks |
@engcom-Lima The object passed to the validate function of a Payment Gateway Validator Instance is an array:
This array contains an an object of the type PaymentDataObjectInterface: magento2/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectInterface.php Lines 1 to 31 in 192b280
My use case here is now to get the order total. The way I can achieve this is by calling the getOrder() functiom: magento2/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectInterface.php Lines 18 to 23 in 192b280
This function now returns an object of the type OrderAdapterInterface. This interface is implemented by the classes OrderAdapter and QuoteAdapter. magento2/app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php Lines 122 to 130 in 192b280
I hope that this explanation now is enough for this obvious bug to be fixed. |
Hi @oneserv-heuser, Thank you for the detailed explanation. Based on it we can proceed with this issue accordingly and therefore confirming this issue again. |
❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-1290 |
@magento I am working on this |
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Cause of the bug
The method always returns null as seen here: QuoteAdapter::getGrandTotalAmount()
The solution
Change the function as follows:
Example
My use case is to use the Gateway Implementation for Payment methods which magento provides and requires me to use.
Specifically I need it for the availability Validator as configured as decribed here.
Here is a code example:
In my code example you can see the use case. If the function getGrandTotalAmount() always returns null (which it does, as it's hardcoded to do that) my payment method will never be available.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: