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 @@