-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #585 from mollie/release/2.19.0
Release/2.19.0
- Loading branch information
Showing
19 changed files
with
253 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Mollie\Payment\Service\Mollie; | ||
|
||
class ShouldRedirectToSuccessPage | ||
{ | ||
public function execute(array $result): bool | ||
{ | ||
if (!isset($result['success'])) { | ||
return false; | ||
} | ||
|
||
return (bool)$result['success']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Mollie\Payment\Service\Order\Lines\Generator; | ||
|
||
use Magento\Framework\Module\Manager; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Payment\Helper\General; | ||
|
||
class GeisswebEuvat implements GeneratorInterface | ||
{ | ||
/** | ||
* @var General | ||
*/ | ||
private $mollieHelper; | ||
|
||
/** | ||
* @var Manager | ||
*/ | ||
private $moduleManager; | ||
|
||
public function __construct( | ||
General $mollieHelper, | ||
Manager $moduleManager | ||
) { | ||
$this->mollieHelper = $mollieHelper; | ||
$this->moduleManager = $moduleManager; | ||
} | ||
|
||
/** | ||
* The Geissweb_Euvat module messes with the trigger_recollect in | ||
* vendor/geissweb/module-euvat/Plugin/Model/Quote.php | ||
* | ||
* which leads to invalid order lines being generated. This is a workaround for that. | ||
* | ||
* @param OrderInterface $order | ||
* @param array $orderLines | ||
* @return array | ||
*/ | ||
public function process(OrderInterface $order, array $orderLines): array | ||
{ | ||
if (!$this->moduleManager->isEnabled('Geissweb_Euvat')) { | ||
return $orderLines; | ||
} | ||
|
||
$forceBaseCurrency = (bool)$this->mollieHelper->useBaseCurrency($order->getStoreId()); | ||
$orderTotal = $forceBaseCurrency ? $order->getBaseGrandTotal() : $order->getGrandTotal(); | ||
$orderLinesTotal = $this->getOrderLinesTotal($orderLines); | ||
|
||
if ($orderTotal == $orderLinesTotal) { | ||
return $orderLines; | ||
} | ||
|
||
$currency = $forceBaseCurrency ? $order->getBaseCurrencyCode() : $order->getOrderCurrencyCode(); | ||
|
||
$orderLines[] = [ | ||
'type' => 'discount', | ||
'name' => 'EU VAT', | ||
'quantity' => 1, | ||
'unitPrice' => $this->mollieHelper->getAmountArray($currency, $orderTotal - $orderLinesTotal), | ||
'totalAmount' => $this->mollieHelper->getAmountArray($currency, $orderTotal - $orderLinesTotal), | ||
'vatRate' => 0, | ||
'vatAmount' => $this->mollieHelper->getAmountArray($currency, 0) | ||
]; | ||
|
||
return $orderLines; | ||
} | ||
|
||
private function getOrderLinesTotal(array $orderLines): float | ||
{ | ||
$total = 0; | ||
foreach ($orderLines as $orderLine) { | ||
$total += $orderLine['totalAmount']['value']; | ||
} | ||
|
||
return $total; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Test/Integration/Plugin/Quote/Api/Item/MakeRecurringProductsUniqueInCartTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Test\Integration\Plugin\Quote\Api\Item; | ||
|
||
use Magento\Quote\Api\Data\CartItemInterface; | ||
use Mollie\Payment\Plugin\Quote\Api\Item\MakeRecurringProductsUniqueInCart; | ||
use Mollie\Payment\Test\Integration\IntegrationTestCase; | ||
|
||
class MakeRecurringProductsUniqueInCartTest extends IntegrationTestCase | ||
{ | ||
public function testDoesNotThrowAnErrorWhenNoBuyRequestIsAvailable(): void | ||
{ | ||
/** @var MakeRecurringProductsUniqueInCart $instance */ | ||
$instance = $this->objectManager->get(MakeRecurringProductsUniqueInCart::class); | ||
|
||
$result = rand(0, 1) === 1; | ||
$outcome = $instance->afterRepresentProduct( | ||
$this->objectManager->create(CartItemInterface::class), | ||
$result | ||
); | ||
|
||
$this->assertEquals($result, $outcome); | ||
} | ||
} |
Oops, something went wrong.