-
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 #458 from mollie/release/2.3.0
Release/2.3.0
- Loading branch information
Showing
16 changed files
with
244 additions
and
20 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
20 changes: 20 additions & 0 deletions
20
GraphQL/Plugin/Quote/PaymentMethodManagement/HideNonGrahpQlMethods.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,20 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\GraphQL\Plugin\Quote\PaymentMethodManagement; | ||
|
||
use Magento\Quote\Api\PaymentMethodManagementInterface; | ||
use Mollie\Payment\Model\Methods\CreditcardVault; | ||
|
||
class HideNonGrahpQlMethods | ||
{ | ||
public function afterGetList(PaymentMethodManagementInterface $subject, array $result) | ||
{ | ||
return array_filter($result, function ($method) { | ||
return !$method instanceof CreditcardVault; | ||
}); | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
Observer/CheckoutSubmitAllAfter/StartTransactionForInstantPurchaseOrders.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,47 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Observer\CheckoutSubmitAllAfter; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
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 Mollie | ||
*/ | ||
private $mollie; | ||
|
||
public function __construct( | ||
Mollie $mollie | ||
) { | ||
$this->mollie = $mollie; | ||
} | ||
|
||
public function execute(Observer $observer) | ||
{ | ||
/** @var OrderInterface $order */ | ||
$order = $observer->getData('order'); | ||
|
||
$payment = $order->getPayment(); | ||
$instantPurchase = $payment->getAdditionalInformation(PaymentConfiguration::MARKER); | ||
if (!$instantPurchase || $instantPurchase != 'true') { | ||
return; | ||
} | ||
|
||
$method = $payment->getMethodInstance(); | ||
if (!$method instanceof CreditcardVault) { | ||
return; | ||
} | ||
|
||
$this->mollie->startTransaction($order); | ||
} | ||
} |
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\Service\InstantPurchase; | ||
|
||
use Mollie\Payment\Config; | ||
|
||
class AvailabilityCheck implements \Magento\InstantPurchase\PaymentMethodIntegration\AvailabilityCheckerInterface | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
public function __construct( | ||
Config $config | ||
) { | ||
$this->config = $config; | ||
} | ||
|
||
public function isAvailable(): bool | ||
{ | ||
return $this->config->isMagentoVaultEnabled(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Test/Integration/GraphQL/Resolver/Checkout/AvailablePaymentMethodsTest.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,65 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Test\Integration\GraphQL\Resolver\Checkout; | ||
|
||
use Magento\Framework\Encryption\Encryptor; | ||
use Magento\Framework\Encryption\EncryptorInterface; | ||
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; | ||
use Magento\Quote\Api\Data\CartInterface; | ||
use Magento\Quote\Model\Quote; | ||
use Mollie\Payment\Test\Integration\GraphQLTestCase; | ||
|
||
class AvailablePaymentMethodsTest extends GraphQLTestCase | ||
{ | ||
/** | ||
* @magentoDataFixture Magento/Sales/_files/quote.php | ||
* @magentoDataFixture Magento/Sales/_files/order.php | ||
* @throws \Exception | ||
* @magentoAppArea graphql | ||
* | ||
* @magentoConfigFixture default_store payment/mollie_general/enabled 1 | ||
* @magentoConfigFixture default_store payment/mollie_methods_creditcard_vault/active 1 | ||
*/ | ||
public function testHidesTheVaultMethod() | ||
{ | ||
$encryptorMock = $this->createMock(Encryptor::class); | ||
$encryptorMock->method('decrypt')->willReturn('test_dummyapikeywhichmustbe30characterslong'); | ||
|
||
$this->objectManager->addSharedInstance($encryptorMock, Encryptor::class); | ||
|
||
/** @var CartInterface $cart */ | ||
$cart = $this->objectManager->create(Quote::class); | ||
$cart->load('test01', 'reserved_order_id'); | ||
$cart->setIsMultiShipping(false); | ||
$cart->save(); | ||
|
||
$maskedQuoteId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class)->execute('test01'); | ||
|
||
$result = $this->graphQlQuery('query { | ||
cart(cart_id: "' . $maskedQuoteId . '") { | ||
available_payment_methods { | ||
code | ||
title | ||
mollie_meta { | ||
image | ||
} | ||
mollie_available_issuers { | ||
name | ||
code | ||
image | ||
svg | ||
} | ||
} | ||
} | ||
}'); | ||
|
||
$this->assertFalse(in_array( | ||
'mollie_methods_creditcard_vault', | ||
array_column($result['cart']['available_payment_methods'], 'code') | ||
)); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...egration/Observer/CheckoutSubmitAllAfter/StartTransactionForInstantPurchaseOrdersTest.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,45 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Test\Integration\Observer\CheckoutSubmitAllAfter; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\InstantPurchase\Model\QuoteManagement\PaymentConfiguration; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Payment\Model\Methods\CreditcardVault; | ||
use Mollie\Payment\Model\Mollie; | ||
use Mollie\Payment\Observer\CheckoutSubmitAllAfter\StartTransactionForInstantPurchaseOrders; | ||
use Mollie\Payment\Test\Integration\IntegrationTestCase; | ||
|
||
class StartTransactionForInstantPurchaseOrdersTest extends IntegrationTestCase | ||
{ | ||
/** | ||
* @magentoDataFixture Magento/Sales/_files/order.php | ||
*/ | ||
public function testCallsTheStartTransactionMethod() | ||
{ | ||
$mollieMock = $this->createMock(Mollie::class); | ||
$mollieMock->expects($this->once())->method('startTransaction'); | ||
|
||
$order = $this->loadOrderById('100000001'); | ||
|
||
// Method must be "mollie_methods_creditcard_vault" | ||
$order->getPayment()->setMethod(CreditcardVault::CODE); | ||
|
||
// Additional information "instant-purchase" must be "true". | ||
$order->getPayment()->setAdditionalInformation(PaymentConfiguration::MARKER, 'true'); | ||
|
||
$observer = $this->objectManager->create(Observer::class); | ||
$observer->setData('order', $order); | ||
|
||
/** @var StartTransactionForInstantPurchaseOrders $instance */ | ||
$instance = $this->objectManager->create(StartTransactionForInstantPurchaseOrders::class, [ | ||
'mollie' => $mollieMock, | ||
]); | ||
|
||
$instance->execute($observer); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -102,4 +102,5 @@ enum PaymentStatusEnum { | |
REFUNDED | ||
ERROR | ||
FAILED | ||
OPEN | ||
} |
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