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 b800473e authored by Robin Westra's avatar Robin Westra

Added sending of invoice emails if enabled in backend

parent e63b0b71
...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model; ...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model;
use Magento\Framework\Webapi\Exception; use Magento\Framework\Webapi\Exception;
use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Framework\App\Area; use Magento\Framework\App\Area;
use Magento\Framework\App\AreaList; use Magento\Framework\App\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder; use Magento\Framework\Phrase\Renderer\Placeholder;
...@@ -71,6 +72,11 @@ class Cron ...@@ -71,6 +72,11 @@ class Cron
*/ */
protected $_orderSender; protected $_orderSender;
/**
* @var InvoiceSender
*/
protected $_invoiceSender;
/** /**
* @var \Magento\Framework\DB\TransactionFactory * @var \Magento\Framework\DB\TransactionFactory
*/ */
...@@ -180,6 +186,7 @@ class Cron ...@@ -180,6 +186,7 @@ class Cron
* @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param OrderSender $orderSender * @param OrderSender $orderSender
* @param InvoiceSender $invoiceSender
* @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Framework\DB\TransactionFactory $transactionFactory
* @param Billing\AgreementFactory $billingAgreementFactory * @param Billing\AgreementFactory $billingAgreementFactory
* @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory * @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
...@@ -195,6 +202,7 @@ class Cron ...@@ -195,6 +202,7 @@ class Cron
\Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\OrderFactory $orderFactory,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
OrderSender $orderSender, OrderSender $orderSender,
InvoiceSender $invoiceSender,
\Magento\Framework\DB\TransactionFactory $transactionFactory, \Magento\Framework\DB\TransactionFactory $transactionFactory,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory, \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory, \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
...@@ -209,6 +217,7 @@ class Cron ...@@ -209,6 +217,7 @@ class Cron
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_orderSender = $orderSender; $this->_orderSender = $orderSender;
$this->_invoiceSender = $invoiceSender;
$this->_transactionFactory = $transactionFactory; $this->_transactionFactory = $transactionFactory;
$this->_billingAgreementFactory = $billingAgreementFactory; $this->_billingAgreementFactory = $billingAgreementFactory;
$this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory; $this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory;
...@@ -1440,12 +1449,14 @@ class Cron ...@@ -1440,12 +1449,14 @@ class Cron
$this->_setPaymentAuthorized(); $this->_setPaymentAuthorized();
$invoiceAutoMail = (bool)$this->_getConfigData( $invoiceAutoMail = (bool)$this->_scopeConfig->isSetFlag(
'send_invoice_update_mail', 'adyen_abstract', $this->_order->getStoreId() \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$this->_order->getStoreId()
); );
if ($invoiceAutoMail) { if ($invoiceAutoMail) {
$invoice->sendEmail(); $this->_invoiceSender->send($invoice);
} }
} else { } else {
$this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order'); $this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
...@@ -1587,4 +1598,4 @@ class Cron ...@@ -1587,4 +1598,4 @@ class Cron
$path = 'payment/' . $paymentMethodCode . '/' . $field; $path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} }
} }
\ No newline at end of file
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