diff --git a/Block/Info/Monei.php b/Block/Info/Monei.php index fed7bb5..67ee74a 100644 --- a/Block/Info/Monei.php +++ b/Block/Info/Monei.php @@ -15,6 +15,12 @@ class Monei extends Info { + private const INFO_PAY_ALLOWED = [ + 'last4', + 'brand', + 'phoneNumber', + ]; + /** * Monei template * @@ -82,4 +88,9 @@ public function getPaymentTitle() return null; } + + public function getInfoPayAllowed(): array + { + return self::INFO_PAY_ALLOWED; + } } diff --git a/Controller/Payment/Complete.php b/Controller/Payment/Complete.php index 9218f34..b4226ae 100644 --- a/Controller/Payment/Complete.php +++ b/Controller/Payment/Complete.php @@ -156,7 +156,7 @@ public function execute() $this->orderRepository->save($order); // send Order email - if ($order->getCanSendNewEmailFlag()) { + if ($order->getCanSendNewEmailFlag() && !$order->getEmailSent()) { try { $this->orderSender->send($order); } catch (\Exception $e) { diff --git a/Observer/SaveOrderBeforeSalesModelQuoteObserver.php b/Observer/SaveOrderBeforeSalesModelQuoteObserver.php index 323a9b3..d782f1a 100644 --- a/Observer/SaveOrderBeforeSalesModelQuoteObserver.php +++ b/Observer/SaveOrderBeforeSalesModelQuoteObserver.php @@ -14,6 +14,7 @@ use Magento\Framework\Event\ObserverInterface; use Magento\Quote\Model\Quote; use Magento\Sales\Model\Order; +use Monei\MoneiPayment\Model\Payment\Monei; class SaveOrderBeforeSalesModelQuoteObserver implements ObserverInterface { @@ -37,6 +38,10 @@ public function execute(Observer $observer): SaveOrderBeforeSalesModelQuoteObser $this->objectCopyService->copyFieldsetToTarget('sales_convert_quote', 'to_order', $quote, $order); + if (in_array($order->getPayment()->getMethod(), Monei::PAYMENT_METHODS_MONEI)) { + $order->setCanSendNewEmailFlag(false); + } + return $this; } } diff --git a/Observer/SaveQuoteSubmitSuccessObserver.php b/Observer/SaveQuoteSubmitSuccessObserver.php new file mode 100644 index 0000000..7a74319 --- /dev/null +++ b/Observer/SaveQuoteSubmitSuccessObserver.php @@ -0,0 +1,36 @@ +getEvent()->getData('order'); + + if (in_array($order->getPayment()->getMethod(), Monei::PAYMENT_METHODS_MONEI)) { + $order->setCanSendNewEmailFlag(true); + } + + return $this; + } +} diff --git a/etc/events.xml b/etc/events.xml index 6ab8e0e..0ec0996 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -10,6 +10,9 @@ + + + diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 676bb23..df4c609 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -21,3 +21,7 @@ "%1 should be numeric value","%1 should be numeric value" "Refund reason","Refund reason" "Pay with Monei","Pay with MONEI" +"method:","Method:" +"last4:","Last 4 digits:" +"brand:","Brand:" +"phoneNumber:","Phone number:" diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index b77822a..5160702 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -38,3 +38,7 @@ "Multibanco payment method is not available in your Monei account. Please enable it in your Monei account to use it.","El método de pago de Multibanco no está disponible en su cuenta de Monei. Por favor, habilítelo en su cuenta de Monei para poder usarlo." "MBWay payment method is not available in your Monei account. Please enable it in your Monei account to use it.","El método de pago de MBWay no está disponible en su cuenta de Monei. Por favor, habilítelo en su cuenta de Monei para poder usarlo." "(Test Mode)","(Modo de Prueba)" +"method:","Método:" +"last4:","Últimos 4 digitos:" +"brand:","Tipo:" +"phoneNumber:","Teléfono:" diff --git a/view/frontend/templates/info/monei.phtml b/view/frontend/templates/info/monei.phtml index 17220bb..7d9459e 100644 --- a/view/frontend/templates/info/monei.phtml +++ b/view/frontend/templates/info/monei.phtml @@ -9,13 +9,28 @@ */ $paymentTitle = $block->getPaymentTitle(); $paymentInfo = $block->getPaymentInfo(); +$infoCard = ''; ?> escapeHtml($paymentTitle) ?> - $payValue) { ?> + $payValue): ?> + getInfoPayAllowed(), true)) : ?> + + + + + + + + +
+ escapeHtml($payValue) ?> +
+ + +
- escapeHtml(__($payKey . ':')) ?> - escapeHtml($payValue) ?> + escapeHtml($infoCard) ?>
- +