We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit f4fbd8b7 authored by Rik ter Beek's avatar Rik ter Beek

#105 add try catch arround sending mail

parent 7ce373bc
...@@ -35,7 +35,6 @@ class Cron ...@@ -35,7 +35,6 @@ class Cron
*/ */
protected $_logger; protected $_logger;
/** /**
* @var Resource\Notification\CollectionFactory * @var Resource\Notification\CollectionFactory
*/ */
...@@ -176,6 +175,8 @@ class Cron ...@@ -176,6 +175,8 @@ class Cron
* @param Billing\AgreementFactory $billingAgreementFactory * @param Billing\AgreementFactory $billingAgreementFactory
* @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory * @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param Api\PaymentRequest $paymentRequest * @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
...@@ -668,8 +669,7 @@ class Cron ...@@ -668,8 +669,7 @@ class Cron
$isBankTransfer = $this->_isBankTransfer(); $isBankTransfer = $this->_isBankTransfer();
if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') { if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
if (!$this->_order->getEmailSent()) { if (!$this->_order->getEmailSent()) {
$this->_orderSender->send($this->_order); $this->_sendOrderMail();
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
} }
} }
} }
...@@ -973,9 +973,9 @@ class Cron ...@@ -973,9 +973,9 @@ class Cron
if ($this->_paymentMethod != "adyen_boleto") { if ($this->_paymentMethod != "adyen_boleto") {
// send order confirmation mail after invoice creation so merchant can add invoicePDF to this mail // send order confirmation mail after invoice creation so merchant can add invoicePDF to this mail
if (!$this->_order->getEmailSent()) { if (!$this->_order->getEmailSent()) {
$this->_orderSender->send($this->_order); $this->_sendOrderMail();
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
} }
} }
if (($this->_paymentMethod == "c_cash" && if (($this->_paymentMethod == "c_cash" &&
...@@ -987,8 +987,28 @@ class Cron ...@@ -987,8 +987,28 @@ class Cron
} }
} }
/**
* Send order Mail
*
* @return void
*/
private function _sendOrderMail()
{
try {
$this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
} catch(\Exception $exception) {
$this->_adyenLogger->addAdyenNotificationCronjob(
"Exception in Send Mail in Magento. This is an issue in the the core of Magento" .
$exception->getMessage()
);
}
}
/** /**
* Set status on authorisation * Set status on authorisation
*
* @return void
*/ */
private function _setPrePaymentAuthorized() private function _setPrePaymentAuthorized()
{ {
...@@ -1009,6 +1029,7 @@ class Cron ...@@ -1009,6 +1029,7 @@ class Cron
/** /**
* @throws Exception * @throws Exception
* @return void
*/ */
protected function _prepareInvoice() protected function _prepareInvoice()
{ {
...@@ -1220,7 +1241,8 @@ class Cron ...@@ -1220,7 +1241,8 @@ class Cron
/** /**
* @return bool * @return bool
*/ */
protected function _isBankTransfer() { protected function _isBankTransfer()
{
if (strlen($this->_paymentMethod) >= 12 && substr($this->_paymentMethod, 0, 12) == "bankTransfer") { if (strlen($this->_paymentMethod) >= 12 && substr($this->_paymentMethod, 0, 12) == "bankTransfer") {
$isBankTransfer = true; $isBankTransfer = true;
} else { } else {
...@@ -1250,7 +1272,8 @@ class Cron ...@@ -1250,7 +1272,8 @@ class Cron
} }
/** /**
* @param $orderAmount * @param int $paymentId
* @param string $orderCurrencyCode
* @return bool * @return bool
*/ */
protected function _isTotalAmount($paymentId, $orderCurrencyCode) protected function _isTotalAmount($paymentId, $orderCurrencyCode)
...@@ -1267,10 +1290,15 @@ class Cron ...@@ -1267,10 +1290,15 @@ class Cron
->create() ->create()
->getTotalAmount($paymentId); ->getTotalAmount($paymentId);
if($res && isset($res[0]) && is_array($res[0])) { if ($res && isset($res[0]) && is_array($res[0])) {
$amount = $res[0]['total_amount']; $amount = $res[0]['total_amount'];
$orderAmount = $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode); $orderAmount = $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode);
$this->_adyenLogger->addAdyenNotificationCronjob(sprintf('The grandtotal amount is %s and the total order amount that is authorised is: %s', $grandTotal, $orderAmount)); $this->_adyenLogger->addAdyenNotificationCronjob(
sprintf('The grandtotal amount is %s and the total order amount that is authorised is: %s',
$grandTotal,
$orderAmount
)
);
if ($grandTotal == $orderAmount) { if ($grandTotal == $orderAmount) {
$this->_adyenLogger->addAdyenNotificationCronjob('AUTHORISATION has the full amount'); $this->_adyenLogger->addAdyenNotificationCronjob('AUTHORISATION has the full amount');
...@@ -1288,6 +1316,7 @@ class Cron ...@@ -1288,6 +1316,7 @@ class Cron
/** /**
* @throws Exception * @throws Exception
* @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\LocalizedException
* @return void
*/ */
protected function _createInvoice() protected function _createInvoice()
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment