Skip to content

Commit 749f6eb

Browse files
committed
small changes
1 parent 21799ea commit 749f6eb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Controller/Applepay/SaveOrder.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
namespace Buckaroo\Magento2\Controller\Applepay;
2121

2222
use Buckaroo\Magento2\Logging\Log;
23+
use Buckaroo\Magento2\Model\Config\Source\InvoiceHandlingOptions;
24+
use Buckaroo\Magento2\Model\ConfigProvider\Account;
2325
use Magento\Framework\App\Action\Action;
2426
use Magento\Framework\App\Action\Context;
2527
use Magento\Framework\View\Result\Page;
@@ -35,6 +37,7 @@ class SaveOrder extends Common
3537
protected $order;
3638
protected $checkoutSession;
3739
protected $accountConfig;
40+
private $configAccount;
3841

3942
/**
4043
* @param Context $context
@@ -47,6 +50,7 @@ public function __construct(
4750
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
4851
Log $logger,
4952
\Magento\Checkout\Model\Cart $cart,
53+
Account $configAccount,
5054
\Magento\Quote\Model\QuoteManagement $quoteManagement,
5155
\Magento\Customer\Model\Session $customer,
5256
\Magento\Framework\DataObjectFactory $objectFactory,
@@ -69,7 +73,7 @@ public function __construct(
6973
$converter,
7074
$customerSession
7175
);
72-
76+
$this->configAccount = $configAccount;
7377
$this->quoteManagement = $quoteManagement;
7478
$this->customer = $customer;
7579
$this->objectFactory = $objectFactory;
@@ -124,8 +128,14 @@ public function execute()
124128

125129
$payment = $quote->getPayment();
126130
$payment->setMethod(Applepay::PAYMENT_METHOD_CODE);
127-
$quote->setPayment($payment);
128131

132+
$invoiceHandlingConfig = $this->configAccount->getInvoiceHandling($this->order->getStore());
133+
134+
if ($invoiceHandlingConfig == InvoiceHandlingOptions::SHIPMENT) {
135+
$payment->setAdditionalInformation(InvoiceHandlingOptions::INVOICE_HANDLING, $invoiceHandlingConfig);
136+
$payment->save();
137+
$quote->setPayment($payment);
138+
}
129139
$quote->collectTotals()->save();
130140

131141
$obj = $this->objectFactory->create();
@@ -182,3 +192,4 @@ public function execute()
182192
return $this->commonResponse($data, $errorMessage);
183193
}
184194
}
195+

Observer/SalesOrderShipmentAfter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function execute(Observer $observer)
184184
$this->logger->addDebug(strpos($paymentMethodCode, 'buckaroo_magento2') != false . "AAAAAAAAA");
185185
$this->logger->addDebug(json_encode($order) . '|ordeeeer info|');
186186
// $this->logger->addDebug(json_encode($this->isInvoiceCreatedAfterShipment($payment)) . '|is invoice created after shipment|');
187-
// if (strpos($paymentMethodCode, 'buckaroo_magento2')) {
187+
// if (strpos($paymentMethodCode, 'buckaroo_magento2') !== false) {
188188
$this->logger->addDebug('|inside last iff|');
189189
$this->logger->addDebug($paymentMethod->getConfigPaymentAction() .'|config payment action|');
190190
if ($paymentMethod->getConfigPaymentAction() == 'authorize') {

0 commit comments

Comments
 (0)