Skip to content

Commit

Permalink
Merge pull request #97 from mwarzybok-sumoheavy/feature/SP-726
Browse files Browse the repository at this point in the history
SP-726 M2 Plugin: Check viability of moving refund to observer
  • Loading branch information
p-maguire authored Oct 31, 2023
2 parents 47d68d5 + 0497515 commit 769a09d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Model/BitPayRefundOnline.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public function execute(\Magento\Sales\Model\Order\Creditmemo $creditMemo): void
return;
}

$baseOrderRefund = $this->priceCurrency->round(
$creditMemo->getOrder()->getBaseTotalRefunded() + $creditMemo->getBaseGrandTotal()
);
$baseOrderRefund = $this->priceCurrency->round($creditMemo->getBaseGrandTotal());
$client = $this->bitpayClient->initialize();
$invoiceId = $bitPayInvoiceData['invoice_id'];
$bitPayInvoice = $client->getInvoice($invoiceId);
Expand Down
8 changes: 3 additions & 5 deletions Test/Unit/Model/BitPayRefundOnlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BitPayRefundOnlineTest extends TestCase
private const ORDER_ID = '123213';
private const INVOICE_ID = '123132132131';
private const BASE_ORDER_REFUND = 13.00;
private const ORDER_BASE_TOTAL_REFUNDED = "0";
private const CREDIT_MEMO_BASE_GRAND_TOTAL = "13.00";
private const REFUND_ID = "1112";
private const REFUND_AMOUNT = 13.00;
Expand Down Expand Up @@ -114,7 +113,7 @@ public function testDoRefund(): void
);

// then
$creditMemo->expects(self::exactly(2))->method('getOrder')->willReturn($order);
$creditMemo->expects(self::once())->method('getOrder')->willReturn($order);
$order->expects(self::exactly(2))->method('getPayment')->willReturn($payment);
$payment->expects(self::once())->method('getMethod')->willReturn(Config::BITPAY_PAYMENT_METHOD_NAME);
$bitPayInvoiceRepository->expects(self::once())->method('getByOrderId')->with(self::ORDER_ID)->willReturn([
Expand Down Expand Up @@ -158,8 +157,8 @@ public function testThrowLocalizedExceptionForBitPayRefundExceptionWithSpecificM
);

// then
$creditMemo->expects(self::exactly(2))->method('getOrder')->willReturn($order);
$order->expects(self::exactly(1))->method('getPayment')->willReturn($payment);
$creditMemo->expects(self::once())->method('getOrder')->willReturn($order);
$order->expects(self::once())->method('getPayment')->willReturn($payment);
$payment->expects(self::once())->method('getMethod')->willReturn(Config::BITPAY_PAYMENT_METHOD_NAME);
$bitPayInvoiceRepository->expects(self::once())->method('getByOrderId')->with(self::ORDER_ID)->willReturn([
'invoice_id' => self::INVOICE_ID
Expand Down Expand Up @@ -224,7 +223,6 @@ private function getOrderMock(): \PHPUnit\Framework\MockObject\MockObject|\Magen
{
$order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->getMock();
$order->method('getId')->willReturn(self::ORDER_ID);
$order->method('getBaseTotalRefunded')->willReturn(self::ORDER_BASE_TOTAL_REFUNDED);

return $order;
}
Expand Down

0 comments on commit 769a09d

Please sign in to comment.