adyen-magento2
adyen-magento2 copied to clipboard
[PW-8375] Possible incorrect implementation of `isFullInvoiceAmountManuallyCaptured`
Adyen\Payment\Helper\Invoice::isFullInvoiceAmountManuallyCaptured
seems like it may have a bug on multi-currency setups.
I'm not sure about generic reproduction steps but this is an accurate description of behaviour I'm seeing in prod:
- Magento: GBP base currency with alternative currencies enabled
- Adyen: GBP only
- Enable manual capture
- As customer select alternative currency (JPY and USD both seem affected)
- Place order
- As admin, note order with base_grand_total = 1000 GBP, grand_total = 150000 JPY
- Create invoice, observe same figures on invoice
- Capture from interface and await webhook
Observe:
- adyen_invoice has amount = 1000; status = successful
- adyen_order_payment has amount = 1000; status = manually captured
-
isFullInvoiceAmountManuallyCaptured
compares$invoiceAmountCents
based onsales_invoice.grand_total
in alternative currency:
with$invoiceAmountCents = $this->adyenDataHelper->formatAmount( $invoice->getGrandTotal(), $invoice->getOrderCurrencyCode() );
$invoiceCapturedAmount
based onadyen_invoice.amount
in store base currency:
and therefore returns$invoiceCapturedAmount += $adyenInvoice[\Adyen\Payment\Api\Data\InvoiceInterface::AMOUNT];
false
-
Magento\Sales\Model\Order\Invoice::pay()
is never called and order remains in pending state
Expected behavior
isFullInvoiceAmountManuallyCaptured
should be aware of the adyen_invoice.amount
currency and do a comparison on the appropriate sales_order.<base_>grand_total
amount
Magento version
"name": "adyen/module-payment",
"version": "8.14.0",
"name": "adyen/php-api-library",
"version": "13.0.4",
"name": "adyen/php-webhook-module",
"version": "0.6.0",
"name": "magento/magento2-base",
"version": "2.4.3-p3",