20
20
namespace Buckaroo \Magento2 \Controller \Applepay ;
21
21
22
22
use Buckaroo \Magento2 \Logging \Log ;
23
+ use Buckaroo \Magento2 \Model \Config \Source \InvoiceHandlingOptions ;
24
+ use Buckaroo \Magento2 \Model \ConfigProvider \Account ;
23
25
use Magento \Framework \App \Action \Action ;
24
26
use Magento \Framework \App \Action \Context ;
25
27
use Magento \Framework \View \Result \Page ;
@@ -35,6 +37,7 @@ class SaveOrder extends Common
35
37
protected $ order ;
36
38
protected $ checkoutSession ;
37
39
protected $ accountConfig ;
40
+ private $ configAccount ;
38
41
39
42
/**
40
43
* @param Context $context
@@ -47,6 +50,7 @@ public function __construct(
47
50
\Magento \Framework \Controller \Result \JsonFactory $ resultJsonFactory ,
48
51
Log $ logger ,
49
52
\Magento \Checkout \Model \Cart $ cart ,
53
+ Account $ configAccount ,
50
54
\Magento \Quote \Model \QuoteManagement $ quoteManagement ,
51
55
\Magento \Customer \Model \Session $ customer ,
52
56
\Magento \Framework \DataObjectFactory $ objectFactory ,
@@ -69,7 +73,7 @@ public function __construct(
69
73
$ converter ,
70
74
$ customerSession
71
75
);
72
-
76
+ $ this -> configAccount = $ configAccount ;
73
77
$ this ->quoteManagement = $ quoteManagement ;
74
78
$ this ->customer = $ customer ;
75
79
$ this ->objectFactory = $ objectFactory ;
@@ -126,6 +130,14 @@ public function execute()
126
130
$ payment ->setMethod (Applepay::PAYMENT_METHOD_CODE );
127
131
$ quote ->setPayment ($ payment );
128
132
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
+ }
129
141
$ quote ->collectTotals ()->save ();
130
142
131
143
$ obj = $ this ->objectFactory ->create ();
0 commit comments