diff --git a/Block/Info/Base.php b/Block/Info/Base.php index 146ca83a70e..92b87db7646 100644 --- a/Block/Info/Base.php +++ b/Block/Info/Base.php @@ -94,9 +94,7 @@ public function getExpiresAt(): ?string public function getPaymentLink($storeId = null): ?string { - if (!$this->config->addPaymentLinkMessage($storeId) || - $this->config->paymentLinkUseCustomEmailTemplate($storeId) - ) { + if (!$this->config->addPaymentLinkMessage($storeId)) { return null; } diff --git a/Config.php b/Config.php index 8bc7ff9b65b..6613d427cfe 100644 --- a/Config.php +++ b/Config.php @@ -72,8 +72,6 @@ class Config const PAYMENT_PAYMENTLINK_NEW_STATUS = 'payment/mollie_methods_paymentlink/order_status_new'; const PAYMENT_PAYMENTLINK_ADD_MESSAGE = 'payment/mollie_methods_paymentlink/add_message'; const PAYMENT_PAYMENTLINK_MESSAGE = 'payment/mollie_methods_paymentlink/message'; - const PAYMENT_PAYMENTLINK_USE_CUSTOM_EMAIL_TEMPLATE = 'payment/mollie_methods_paymentlink/use_custom_email_template'; - const PAYMENT_PAYMENTLINK_EMAIL_TEMPLATE = 'payment/mollie_methods_paymentlink/email_template'; const PAYMENT_USE_CUSTOM_PAYMENTLINK_URL = 'payment/mollie_general/use_custom_paymentlink_url'; const PAYMENT_CUSTOM_PAYMENTLINK_URL = 'payment/mollie_general/custom_paymentlink_url'; const PAYMENT_POINTOFSALE_ALLOWED_CUSTOMER_GROUPS = 'payment/mollie_methods_pointofsale/allowed_customer_groups'; @@ -532,22 +530,6 @@ public function paymentLinkMessage($storeId = null): string ); } - public function paymentLinkUseCustomEmailTemplate(int $storeId = null): string - { - return $this->getPath( - static::PAYMENT_PAYMENTLINK_USE_CUSTOM_EMAIL_TEMPLATE, - $storeId - ); - } - - public function paymentLinkEmailTemplate(int $storeId = null): string - { - return $this->getPath( - static::PAYMENT_PAYMENTLINK_EMAIL_TEMPLATE, - $storeId - ); - } - public function useCustomPaymentLinkUrl($storeId = null): bool { return $this->isSetFlag(static::PAYMENT_USE_CUSTOM_PAYMENTLINK_URL, $storeId); diff --git a/Plugin/Sales/Model/Order/Email/Sender/SendPaymentLinkConfirmation.php b/Plugin/Sales/Model/Order/Email/Sender/SendPaymentLinkConfirmation.php deleted file mode 100644 index 5df2013a06e..00000000000 --- a/Plugin/Sales/Model/Order/Email/Sender/SendPaymentLinkConfirmation.php +++ /dev/null @@ -1,47 +0,0 @@ -config = $config; - $this->paymentLinkConfirmationEmail = $paymentLinkConfirmationEmail; - } - - public function aroundSend(OrderSender $subject, callable $proceed, Order $order, $forceSyncMode = false) - { - // When the `send()` method of the OrderSender is called, we want to call our own class instead. - // But this class is also based on the OrderSender, so we need to check if we are not already in our own class. - if ($order->getPayment()->getMethod() == 'mollie_methods_paymentlink' && - $this->config->paymentLinkUseCustomEmailTemplate((int)$order->getStoreId()) && - !($subject instanceof $this->paymentLinkConfirmationEmail) - ) { - return $this->paymentLinkConfirmationEmail->send($order); - } - - return $proceed($order, $forceSyncMode); - } -} diff --git a/Service/Order/Email/PaymentLinkOrderIdentity.php b/Service/Order/Email/PaymentLinkOrderIdentity.php deleted file mode 100644 index f162f7049c8..00000000000 --- a/Service/Order/Email/PaymentLinkOrderIdentity.php +++ /dev/null @@ -1,42 +0,0 @@ -config = $config; - } - - public function isEnabled() - { - return $this->config->paymentLinkUseCustomEmailTemplate(); - } - - public function getTemplateId() - { - return $this->config->paymentLinkEmailTemplate(); - } -} diff --git a/Service/Order/PaymentLinkConfirmationEmail.php b/Service/Order/PaymentLinkConfirmationEmail.php deleted file mode 100644 index e6e4c88a48f..00000000000 --- a/Service/Order/PaymentLinkConfirmationEmail.php +++ /dev/null @@ -1,78 +0,0 @@ -paymentLinkUrl = $paymentLinkUrl; - } - - protected function prepareTemplate(Order $order) - { - parent::prepareTemplate($order); - - $transportObject = new DataObject($this->templateContainer->getTemplateVars()); - $transportObject->setData('mollie_payment_link', $this->paymentLinkUrl->execute((int)$order->getEntityId())); - - $this->eventManager->dispatch( - 'mollie_email_paymenlink_order_set_template_vars_before', - ['sender' => $this, 'transportObject' => $transportObject] - ); - - $this->templateContainer->setTemplateVars($transportObject->getData()); - } -} diff --git a/Test/Fakes/Service/Magento/PaymentLinkUrlFake.php b/Test/Fakes/Service/Magento/PaymentLinkUrlFake.php deleted file mode 100644 index 3d4b5139232..00000000000 --- a/Test/Fakes/Service/Magento/PaymentLinkUrlFake.php +++ /dev/null @@ -1,44 +0,0 @@ -url = $url; - } - - public function shouldNotBeCalled() - { - $this->shouldNotBeCalled = true; - } - - public function execute(int $orderId): string - { - if ($this->shouldNotBeCalled === true) { - throw new \Exception('This method should not be called'); - } - - if ($this->url !== null) { - return $this->url; - } - - return parent::execute($orderId); - } -} diff --git a/Test/Integration/Block/Info/BaseTest.php b/Test/Integration/Block/Info/BaseTest.php index 4c43269cd79..be349cfb4b5 100644 --- a/Test/Integration/Block/Info/BaseTest.php +++ b/Test/Integration/Block/Info/BaseTest.php @@ -8,8 +8,6 @@ use Magento\Sales\Model\Order\Payment\Info; use Mollie\Payment\Block\Info\Base; -use Mollie\Payment\Service\Magento\PaymentLinkUrl; -use Mollie\Payment\Test\Fakes\Service\Magento\PaymentLinkUrlFake; use Mollie\Payment\Test\Integration\IntegrationTestCase; class BaseTest extends IntegrationTestCase @@ -67,52 +65,4 @@ public function testReturnsTheRemainderAmount() $instance->setData('info', $info); $this->assertEquals('100', $instance->getRemainderAmount()); } - - /** - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/add_message 1 - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/use_custom_email_template 0 - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/message "Click here to complete your payment" - * @return void - */ - public function testReturnsThePaymentLinkMessageWithLink(): void - { - $paymentLinkFake = $this->objectManager->get(PaymentLinkUrlFake::class); - $paymentLinkFake->setUrl('http://www.example.com/mollie/checkout/paymentlink/order/-999/'); - $this->objectManager->addSharedInstance($paymentLinkFake, PaymentLinkUrl::class); - - /** @var Info $info */ - $info = $this->objectManager->create(Info::class); - - /** @var Base $instance */ - $instance = $this->objectManager->create(Base::class); - $instance->setData('info', $info); - - $result = $instance->getPaymentLink(); - - $this->assertStringNotContainsString('%link%', $result); - } - - /** - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/add_message 1 - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/use_custom_email_template 1 - * @magentoConfigFixture current_store payment/mollie_methods_paymentlink/message "Click here to complete your payment" - * @return void - */ - public function testReturnsNothingWhenPaymentLinkMailIsActive(): void - { - $paymentLinkFake = $this->objectManager->get(PaymentLinkUrlFake::class); - $paymentLinkFake->shouldNotBeCalled(); - $this->objectManager->addSharedInstance($paymentLinkFake, PaymentLinkUrl::class); - - /** @var Info $info */ - $info = $this->objectManager->create(Info::class); - - /** @var Base $instance */ - $instance = $this->objectManager->create(Base::class); - $instance->setData('info', $info); - - $result = $instance->getPaymentLink(); - - $this->assertNull($result); - } } diff --git a/etc/adminhtml/methods/paymentlink.xml b/etc/adminhtml/methods/paymentlink.xml index afb3c235c2d..224c1f61ac8 100644 --- a/etc/adminhtml/methods/paymentlink.xml +++ b/etc/adminhtml/methods/paymentlink.xml @@ -36,26 +36,7 @@ 1 - - - Magento\Config\Model\Config\Source\Yesno - payment/mollie_methods_paymentlink/use_custom_email_template - - 1 - - - - - Magento\Config\Model\Config\Source\Email\Template - payment/mollie_methods_paymentlink/email_template - - 1 - 1 - - - Magento\Config\Model\Config\Source\Yesno @@ -66,7 +47,7 @@ 1 - + Mollie\Payment\Model\Adminhtml\Source\NewStatus payment/mollie_methods_paymentlink/order_status_new @@ -74,7 +55,7 @@ 1 - Magento\Payment\Model\Config\Source\Allspecificcountries @@ -83,7 +64,7 @@ 1 - Magento\Directory\Model\Config\Source\Country @@ -93,7 +74,7 @@ 1 - payment/mollie_methods_paymentlink/min_order_total @@ -101,7 +82,7 @@ 1 - payment/mollie_methods_paymentlink/max_order_total @@ -109,7 +90,7 @@ 1 - payment/mollie_methods_paymentlink/payment_surcharge_type @@ -118,7 +99,7 @@ 1 - payment/mollie_methods_paymentlink/payment_surcharge_fixed_amount @@ -129,7 +110,7 @@ fixed_fee,fixed_fee_and_percentage - payment/mollie_methods_paymentlink/payment_surcharge_percentage @@ -140,7 +121,7 @@ percentage,fixed_fee_and_percentage - payment/mollie_methods_paymentlink/payment_surcharge_limit @@ -152,7 +133,7 @@ percentage,fixed_fee_and_percentage - payment/mollie_methods_paymentlink/payment_surcharge_tax_class @@ -162,7 +143,7 @@ fixed_fee,percentage,fixed_fee_and_percentage - validate-number @@ -171,7 +152,7 @@ 1 - validate-digits-range digits-range-1-365 diff --git a/etc/config.xml b/etc/config.xml index a8578928034..6aca2483da0 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -430,8 +430,6 @@ 1 Mollie\Payment\Model\Methods\Paymentlink Mollie: Payment Link - 0 - mollie_payment_methods_mollie_methods_paymentlink_email_template {ordernumber} order order diff --git a/etc/di.xml b/etc/di.xml index e601561a817..4d3d9700cfa 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -366,10 +366,6 @@ - - - - diff --git a/etc/email_templates.xml b/etc/email_templates.xml index 2a38e61dc83..d0e3d60ebf8 100644 --- a/etc/email_templates.xml +++ b/etc/email_templates.xml @@ -1,5 +1,4 @@