From 1575bb9bd7d868cce5506b55aae3d2bca5d5c8e4 Mon Sep 17 00:00:00 2001 From: andrii-onufriichuk <117644505+andrii-onufriichuk@users.noreply.github.com> Date: Mon, 27 Mar 2023 13:04:41 +0300 Subject: [PATCH] Reworked clearpay pricing to work with final price (#24) --- Test/Unit/ViewModel/ClearpayMessagingTest.php | 6 +++--- ViewModel/Clearpay.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Test/Unit/ViewModel/ClearpayMessagingTest.php b/Test/Unit/ViewModel/ClearpayMessagingTest.php index 3c6c937e..974e3db8 100644 --- a/Test/Unit/ViewModel/ClearpayMessagingTest.php +++ b/Test/Unit/ViewModel/ClearpayMessagingTest.php @@ -36,8 +36,8 @@ protected function setUp(): void { $this->configMock = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); $productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class)->getMock(); - $this->productMock = $this->getMockBuilder(ProductInterface::class)->addMethods(['getRvvupRestricted']) - ->getMockForAbstractClass(); + $this->productMock = $this->getMockBuilder(ProductInterface::class) + ->addMethods(['getRvvupRestricted','getFinalPrice'])->getMockForAbstractClass(); $thresholdProviderMock = $this->getMockBuilder(ThresholdProvider::class)->disableOriginalConstructor() ->onlyMethods(['get'])->getMock(); $thresholdProviderMock->method('get')->with('CLEARPAY') @@ -175,7 +175,7 @@ private function configureProduct(bool $restricted, float $price) $this->productMock->method('getRvvupRestricted') ->willReturn($restricted); - $this->productMock->method('getPrice') + $this->productMock->method('getFinalPrice') ->willReturn($price); $this->taxHelperMock->method('getTaxPrice')->willReturn($price); diff --git a/ViewModel/Clearpay.php b/ViewModel/Clearpay.php index 1067cde9..3046c129 100644 --- a/ViewModel/Clearpay.php +++ b/ViewModel/Clearpay.php @@ -316,9 +316,9 @@ private function getThresholdsByProviderAndCurrency() public function getPrice(ProductInterface $product): float { if ($this->taxConfig->getPriceDisplayType() == TaxConfig::DISPLAY_TYPE_BOTH) { - return $this->taxHelper->getTaxPrice($product, (float)$product->getPrice(), true); + return $this->taxHelper->getTaxPrice($product, (float)$product->getFinalPrice(), true); } - return $this->taxHelper->getTaxPrice($product, (float)$product->getPrice()); + return $this->taxHelper->getTaxPrice($product, (float)$product->getFinalPrice()); } }