diff --git a/Controller/Applepay/SaveOrder.php b/Controller/Applepay/SaveOrder.php index 6b6ca60a8..89ee30f18 100644 --- a/Controller/Applepay/SaveOrder.php +++ b/Controller/Applepay/SaveOrder.php @@ -20,6 +20,8 @@ namespace Buckaroo\Magento2\Controller\Applepay; use Buckaroo\Magento2\Logging\Log; +use Buckaroo\Magento2\Model\Config\Source\InvoiceHandlingOptions; +use Buckaroo\Magento2\Model\ConfigProvider\Account; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\View\Result\Page; @@ -35,6 +37,7 @@ class SaveOrder extends Common protected $order; protected $checkoutSession; protected $accountConfig; + private $configAccount; /** * @param Context $context @@ -47,6 +50,7 @@ public function __construct( \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, Log $logger, \Magento\Checkout\Model\Cart $cart, + Account $configAccount, \Magento\Quote\Model\QuoteManagement $quoteManagement, \Magento\Customer\Model\Session $customer, \Magento\Framework\DataObjectFactory $objectFactory, @@ -69,7 +73,7 @@ public function __construct( $converter, $customerSession ); - + $this->configAccount = $configAccount; $this->quoteManagement = $quoteManagement; $this->customer = $customer; $this->objectFactory = $objectFactory; @@ -126,6 +130,14 @@ public function execute() $payment->setMethod(Applepay::PAYMENT_METHOD_CODE); $quote->setPayment($payment); + + $invoiceHandlingConfig = $this->configAccount->getInvoiceHandling($this->order->getStore()); + + if ($invoiceHandlingConfig == InvoiceHandlingOptions::SHIPMENT) { + $payment->setAdditionalInformation(InvoiceHandlingOptions::INVOICE_HANDLING, $invoiceHandlingConfig); + $payment->save(); + $quote->setPayment($payment); + } $quote->collectTotals()->save(); $obj = $this->objectFactory->create(); diff --git a/Observer/SetTransactionOnInvoiceObserver.php b/Observer/SetTransactionOnInvoiceObserver.php index 276efc315..abf3550a1 100644 --- a/Observer/SetTransactionOnInvoiceObserver.php +++ b/Observer/SetTransactionOnInvoiceObserver.php @@ -61,7 +61,7 @@ public function __construct( } /** - * Set transaction id on invoiced for invoice after shippment + * Set transaction id on invoiced for invoice after shipment * * @param Observer $observer * @return $this