diff --git a/Service/Order/TransactionPart/CardToken.php b/Service/Order/TransactionPart/CardToken.php index 47966b1221a..dfc79112975 100644 --- a/Service/Order/TransactionPart/CardToken.php +++ b/Service/Order/TransactionPart/CardToken.php @@ -22,8 +22,7 @@ class CardToken implements TransactionPartInterface public function process(OrderInterface $order, $apiMethod, array $transaction) { $additionalData = $order->getPayment()->getAdditionalInformation(); - - if (!isset($additionalData['card_token'])) { + if ($order->getPayment()->getMethod() != 'mollie_methods_creditcard' || !isset($additionalData['card_token'])) { return $transaction; } diff --git a/Test/Integration/Service/Order/TransactionPart/CardTokenTest.php b/Test/Integration/Service/Order/TransactionPart/CardTokenTest.php index 58b70e8dce8..a5400873c7d 100644 --- a/Test/Integration/Service/Order/TransactionPart/CardTokenTest.php +++ b/Test/Integration/Service/Order/TransactionPart/CardTokenTest.php @@ -20,6 +20,7 @@ public function testAddsDataForPaymentsApi() { $order = $this->loadOrderById('100000001'); $payment = $order->getPayment(); + $payment->setMethod('mollie_methods_creditcard'); $payment->setAdditionalInformation('card_token', 'abc123'); /** @var CardToken $instance */ @@ -36,6 +37,7 @@ public function testAddsDataForPaymentsApi() public function testAddsDataForOrdersApi() { $order = $this->loadOrderById('100000001'); + $order->getPayment()->setMethod('mollie_methods_creditcard'); $payment = $order->getPayment(); $payment->setAdditionalInformation('card_token', 'abc123'); @@ -53,6 +55,25 @@ public function testAddsDataForOrdersApi() public function testDoesNotChangeTheTransactionWhenNoCardTokenIsPresent() { $order = $this->loadOrderById('100000001'); + $order->getPayment()->setMethod('mollie_methods_creditcard'); + + /** @var CardToken $instance */ + $instance = $this->objectManager->create(CardToken::class); + + $transaction = $instance->process($order, Orders::CHECKOUT_TYPE, ['method' => 'creditcard']); + + $this->assertEquals(['method' => 'creditcard'], $transaction); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + */ + public function testDoesATheCardFieldWhenThePaymentMethodIsNotCreditcard() + { + $order = $this->loadOrderById('100000001'); + $payment = $order->getPayment(); + $payment->setMethod('checkmo'); + $payment->setAdditionalInformation('card_token', 'abc123'); /** @var CardToken $instance */ $instance = $this->objectManager->create(CardToken::class); diff --git a/composer.json b/composer.json index 0cc1768c8c9..c49d2c11821 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "1.23.0", + "version": "1.23.1", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 843a8e853d8..d2d40e06a94 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v1.23.0 + v1.23.1 0 0 test