Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Helper/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,11 @@ public function isFullInvoiceAmountManuallyCaptured(InvoiceModel $invoice): bool
}
}

$invoiceChargedCurrency = $this->chargedCurrencyHelper->getInvoiceAmountCurrency($invoice);

$invoiceAmountCents = $this->adyenDataHelper->formatAmount(
$invoice->getGrandTotal(),
$invoice->getOrderCurrencyCode()
$invoiceChargedCurrency->getAmount(),
$invoiceChargedCurrency->getCurrencyCode()
);

$invoiceCapturedAmountCents = $this->adyenDataHelper->formatAmount(
Expand Down
22 changes: 21 additions & 1 deletion Test/Unit/Helper/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ public function testHandleCaptureWebhook()
$adyenAmountCurrencyMock->method('getAmount')->willReturn(10);
$adyenAmountCurrencyMock->method('getCurrencyCode')->willReturn('EUR');

$invoiceAmountCurrency = $this->createMock(AdyenAmountCurrency::class);

$chargedCurrencyMock = $this->createMock(ChargedCurrency::class);
$chargedCurrencyMock->method('getOrderAmountCurrency')->willReturn($adyenAmountCurrencyMock);
$chargedCurrencyMock->method('getInvoiceAmountCurrency')->willReturn($invoiceAmountCurrency);

$invoiceHelper = $this->createInvoiceHelper(
$contextMock,
Expand Down Expand Up @@ -277,6 +280,17 @@ public function testIsFullInvoiceAmountManuallyCaptured()
],
]);

$invoiceAmountCurrency = $this->createMock(AdyenAmountCurrency::class);
$invoiceAmountCurrency->expects($this->once())
->method('getAmount')
->willReturn(1000);
$invoiceAmountCurrency->expects($this->once())
->method('getCurrencyCode')
->willReturn('EUR');

$chargedCurrencyMock = $this->createMock(ChargedCurrency::class);
$chargedCurrencyMock->method('getInvoiceAmountCurrency')->willReturn($invoiceAmountCurrency);

$invoiceHelper = $this->createInvoiceHelper(
null,
null,
Expand All @@ -286,7 +300,13 @@ public function testIsFullInvoiceAmountManuallyCaptured()
null,
null,
null,
$adyenInvoiceCollectionMock
$adyenInvoiceCollectionMock,
null,
null,
null,
null,
null,
$chargedCurrencyMock
);

$invoiceMock = $this->createConfiguredMock(InvoiceModel::class, [
Expand Down
Loading