Email should be send in Ipn controller, not in success page, because it cause sometimes dublicated emails or not sending email at all if user closes the page after payment too fast.
Please adjust the flow of email sending. Something like this in _handleCapture and _handleAuthorization
if (!$this->_order->getEmailSent()) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$emailSender = $objectManager->create('\Magento\Sales\Model\Order\Email\Sender\OrderSender');
$emailSender->send($this->_order);
}
Also, it would be nice if we have the transaction ID saved somewhere. And payment method information also, like paid with Mastercard or Debit Card or Visa and etc.
$this->_order->setNetopiaId($this->getRealOrderId($this->_objPmReq->objPmNotify->purchaseId));
Email should be send in Ipn controller, not in success page, because it cause sometimes dublicated emails or not sending email at all if user closes the page after payment too fast.
Please adjust the flow of email sending. Something like this in _handleCapture and _handleAuthorization
Also, it would be nice if we have the transaction ID saved somewhere. And payment method information also, like paid with Mastercard or Debit Card or Visa and etc.