Skip to content

Commit ce33997

Browse files
Merge pull request #1134 from buckaroo-it/BP-4031-Invoice-on-shipment-setting-fails-to-generate-invoices-for-Apple-Pay-orders-created-via-cart-page
Bp 4031 invoice on shipment setting fails to generate invoices for apple pay orders created via cart page
2 parents a3d1ac0 + 94093b6 commit ce33997

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Controller/Applepay/SaveOrder.php

Lines changed: 13 additions & 1 deletion
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;
@@ -126,6 +130,14 @@ public function execute()
126130
$payment->setMethod(Applepay::PAYMENT_METHOD_CODE);
127131
$quote->setPayment($payment);
128132

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

131143
$obj = $this->objectFactory->create();

Observer/SetTransactionOnInvoiceObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(
6161
}
6262

6363
/**
64-
* Set transaction id on invoiced for invoice after shippment
64+
* Set transaction id on invoiced for invoice after shipment
6565
*
6666
* @param Observer $observer
6767
* @return $this

0 commit comments

Comments
 (0)