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 ;
@@ -124,8 +128,14 @@ public function execute()
124
128
125
129
$ payment = $ quote ->getPayment ();
126
130
$ payment ->setMethod (Applepay::PAYMENT_METHOD_CODE );
127
- $ quote ->setPayment ($ payment );
128
131
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
+ }
129
139
$ quote ->collectTotals ()->save ();
130
140
131
141
$ obj = $ this ->objectFactory ->create ();
@@ -182,3 +192,4 @@ public function execute()
182
192
return $ this ->commonResponse ($ data , $ errorMessage );
183
193
}
184
194
}
195
+
0 commit comments