Skip to content

Commit

Permalink
Merge pull request #509 from mollie/release/2.9.0
Browse files Browse the repository at this point in the history
Release/2.9.0
  • Loading branch information
Marvin-Magmodules committed Apr 4, 2022
2 parents edaabdc + 936649a commit d0a8faa
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/setup-di-compile-with-replacements.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
MAGENTO_VERSION: 2.3.6-p1
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
MAGENTO_VERSION: 2.3.6-p1
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Module\Manager;
use Magento\InstantPurchase\Model\QuoteManagement\PaymentConfiguration;
use Magento\Sales\Api\Data\OrderInterface;
use Mollie\Payment\Model\Methods\CreditcardVault;
use Mollie\Payment\Model\Mollie;

class StartTransactionForInstantPurchaseOrders implements ObserverInterface
{
/**
* @var Manager
*/
private $moduleManager;

/**
* @var Mollie
*/
Expand All @@ -26,8 +32,10 @@ class StartTransactionForInstantPurchaseOrders implements ObserverInterface
private $redirectUrl = null;

public function __construct(
Manager $moduleManager,
Mollie $mollie
) {
$this->moduleManager = $moduleManager;
$this->mollie = $mollie;
}

Expand All @@ -38,6 +46,10 @@ public function getRedirectUrl(): ?string

public function execute(Observer $observer): void
{
if (!$this->moduleManager->isEnabled('Magento_InstantPurchase')) {
return;
}

if (!$observer->hasData('order')) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(
/**
* @param CartItemInterface $item
* @param bool $result
* @param ProductInterface $product
* @return bool
*/
public function afterRepresentProduct(CartItemInterface $item, bool $result): bool
Expand Down
2 changes: 1 addition & 1 deletion Plugin/Quote/Api/ParseMollieMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function beforeAddProduct(
'recurring_metadata' => $request->getData('recurring_metadata'),
]);

return [$product, $requestInfo, $processMode];
return [$product, $request, $processMode];
}

private function getRequest($request)
Expand Down
6 changes: 4 additions & 2 deletions Service/Order/Lines/Generator/AmastyExtraFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public function process(OrderInterface $order, array $orderLines): array
$forceBaseCurrency = (bool)$this->mollieHelper->useBaseCurrency($order->getStoreId());
$currency = $forceBaseCurrency ? $order->getBaseCurrencyCode() : $order->getOrderCurrencyCode();

$amount = $order->getExtensionAttributes()->getAmextrafeeFeeAmount();
$extensionAttributes = $order->getExtensionAttributes();
$amount = $extensionAttributes->getAmextrafeeFeeAmount() + $extensionAttributes->getAmextrafeeTaxAmount();
if ($forceBaseCurrency) {
$amount = $order->getExtensionAttributes()->getAmextrafeeBaseFeeAmount();
$amount = $extensionAttributes->getAmextrafeeBaseFeeAmount() +
$extensionAttributes->getAmextrafeeBaseTaxAmount();
}

$orderLines[] = [
Expand Down
38 changes: 29 additions & 9 deletions Service/Order/Lines/Generator/WeeeFeeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\Payment\Service\Order\Lines\Generator;

use Magento\Framework\Serialize\SerializerInterface;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\OrderItemInterface;
use Mollie\Payment\Helper\General;
Expand All @@ -27,9 +28,17 @@ class WeeeFeeGenerator implements GeneratorInterface
*/
private $currency;

public function __construct(General $mollieHelper)
{
/**
* @var SerializerInterface
*/
private $serializer;

public function __construct(
General $mollieHelper,
SerializerInterface $serializer
) {
$this->mollieHelper = $mollieHelper;
$this->serializer = $serializer;
}

public function process(OrderInterface $order, array $orderLines): array
Expand All @@ -54,12 +63,7 @@ private function getWeeeFeeOrderLine(OrderInterface $order): ?array

/** @var OrderItemInterface $item */
foreach ($weeeItems as $item) {
$amount = $item->getWeeeTaxAppliedAmount();
if ($this->forceBaseCurrency) {
$amount = $item->getBaseWeeeTaxAppliedAmount();
}

$total += $amount;
$total += $this->getWeeeAmountForItem($item);
}

return [
Expand All @@ -84,7 +88,7 @@ private function getTitle(array $items): string
{
/** @var OrderItemInterface $item */
foreach ($items as $item) {
$json = json_decode($item->getWeeeTaxApplied(), true);
$json = $this->serializer->unserialize($item->getWeeeTaxApplied());

if (!$json) {
continue;
Expand All @@ -99,4 +103,20 @@ private function getTitle(array $items): string

return 'FPT';
}

private function getWeeeAmountForItem(OrderItemInterface $item): float
{
$total = 0.0;
$json = $this->serializer->unserialize($item->getWeeeTaxApplied());
foreach ($json as $item) {
$amount = $item['row_amount_incl_tax'];
if ($this->forceBaseCurrency) {
$amount = $item['base_row_amount_incl_tax'];
}

$total += $amount;
}

return $total;
}
}
7 changes: 4 additions & 3 deletions Service/PaymentFee/Calculate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ public function __construct(
*/
public function forCart(CartInterface $cart, Total $total)
{
if (isset($this->cache[$cart->getId()])) {
return $this->cache[$cart->getId()];
$key = $cart->getId() . '-' . $cart->getPayment()->getMethod();
if (isset($this->cache[$key])) {
return $this->cache[$key];
}

if (!$this->config->isAvailableForMethod($cart)) {
Expand All @@ -87,7 +88,7 @@ public function forCart(CartInterface $cart, Total $total)
$result = $this->calculatePaymentFee($cart, $total);
$this->maximumSurcharge->calculate($cart, $result);

$this->cache[$cart->getId()] = $result;
$this->cache[$key] = $result;
return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
namespace Mollie\Payment\Test\Integration\GraphQL\Resolver\Cart;

use GraphQL\Type\Definition\FieldDefinition;
use Magento\Framework\App\ProductMetadataInterface;
use Mollie\Payment\GraphQL\Resolver\Cart\PaymentMethodMeta;
use Mollie\Payment\Test\Integration\IntegrationTestCase;
use Mollie\Payment\Test\Integration\GraphQLTestCase;

class PaymentMethodMetaTest extends IntegrationTestCase
class PaymentMethodMetaTest extends GraphQLTestCase
{
/**
* @magentoAppArea graphql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
use Mollie\Payment\Api\Data\PaymentTokenInterface;
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
use Mollie\Payment\GraphQL\Resolver\Checkout\PaymentToken;
use Mollie\Payment\Test\Integration\GraphQLTestCase;
use Mollie\Payment\Test\Integration\IntegrationTestCase;

/**
* @magentoAppArea graphql
*/
class PaymentTokenTest extends IntegrationTestCase
class PaymentTokenTest extends GraphQLTestCase
{
protected function setUpWithoutVoid()
{
parent::setUpWithoutVoid();

$version = $this->objectManager->get(ProductMetadataInterface::class)->getVersion();
if (version_compare($version, '2.3', '<=')) {
$this->markTestSkipped('This test only works on Magento 2.3 and higher.');
Expand Down
7 changes: 7 additions & 0 deletions Test/Integration/GraphQLTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Mollie\Payment\Test\Integration;

use Magento\Framework\GraphQl\Query\Fields as QueryFields;
use Magento\Framework\Module\Manager;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\GraphQl\Controller\GraphQl;
use Magento\GraphQl\Service\GraphQlRequest;
Expand All @@ -25,6 +26,12 @@ class GraphQLTestCase extends IntegrationTestCase

protected function setUpWithoutVoid()
{
/** @var Manager $moduleManager */
$moduleManager = $this->objectManager->get(Manager::class);
if (!$moduleManager->isEnabled('Magento_GraphQl')) {
$this->markTestSkipped('Module Magento_GraphQl is not enabled');
}

$this->json = $this->objectManager->get(SerializerInterface::class);
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Mollie\Payment\Test\Integration\Observer\CheckoutSubmitAllAfter;

use Magento\Framework\Event\Observer;
use Magento\Framework\Module\Manager;
use Magento\InstantPurchase\Model\QuoteManagement\PaymentConfiguration;
use Magento\Sales\Api\Data\OrderInterface;
use Mollie\Payment\Model\Methods\CreditcardVault;
Expand All @@ -16,6 +17,17 @@

class StartTransactionForInstantPurchaseOrdersTest extends IntegrationTestCase
{
protected function setUpWithoutVoid()
{
parent::setUpWithoutVoid();

/** @var Manager $moduleManager */
$moduleManager = $this->objectManager->get(Manager::class);
if (!$moduleManager->isEnabled('Magento_InstantPurchase')) {
$this->markTestSkipped('Module Magento_InstantPurchase is not enabled');
}
}

/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function testReturnsWeeeItems()
$orderItems = $order->getItems();

$item = array_shift($orderItems);
$item->setWeeeTaxApplied('[{"row_amount_incl_tax": "10", "base_row_amount_incl_tax": "10"}]');
$item->setWeeeTaxAppliedAmount(10);
$item->setBaseWeeeTaxAppliedAmount(10);

/** @var WeeeFeeGenerator $instance */
$instance = $this->objectManager->create(WeeeFeeGenerator::class);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/magento2",
"description": "Mollie Payment Module for Magento 2",
"version": "2.8.0",
"version": "2.9.0",
"keywords": [
"mollie",
"payment",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<default>
<payment>
<mollie_general>
<version>v2.8.0</version>
<version>v2.9.0</version>
<active>0</active>
<enabled>0</enabled>
<type>test</type>
Expand Down

0 comments on commit d0a8faa

Please sign in to comment.