@@ -144,56 +144,56 @@ class Process extends Action
144
144
* @param Factory $configProviderFactory
145
145
* @param OrderSender $orderSender
146
146
* @param OrderStatusFactory $orderStatusFactory
147
- * @param Session $checkoutSession,
148
- * @param CustomerSession $customerSession,
149
- * @param CustomerRepositoryInterface $customerRepository,
150
- * @param SessionFactory $sessionFactory,
151
- * @param Customer $customerModel,
152
- * @param CustomerFactory $customerFactory,
153
- * @param OrderService $orderService,
154
- * @param ManagerInterface $eventManager,
155
- * @param Recreate $quoteRecreate,
147
+ * @param Session $checkoutSession
148
+ * @param CustomerSession $customerSession
149
+ * @param CustomerRepositoryInterface $customerRepository
150
+ * @param SessionFactory $sessionFactory
151
+ * @param Customer $customerModel
152
+ * @param CustomerFactory $customerFactory
153
+ * @param OrderService $orderService
154
+ * @param ManagerInterface $eventManager
155
+ * @param Recreate $quoteRecreate
156
156
* @param LockManagerWrapper $lockManager
157
- *
158
157
* @throws Exception
159
158
*/
160
159
public function __construct (
161
- Context $ context ,
162
- Data $ helper ,
163
- Cart $ cart ,
164
- Order $ order ,
165
- Quote $ quote ,
166
- TransactionInterface $ transaction ,
167
- Log $ logger ,
168
- Factory $ configProviderFactory ,
169
- OrderSender $ orderSender ,
170
- OrderStatusFactory $ orderStatusFactory ,
171
- Session $ checkoutSession ,
172
- CustomerSession $ customerSession ,
160
+ Context $ context ,
161
+ Data $ helper ,
162
+ Cart $ cart ,
163
+ Order $ order ,
164
+ Quote $ quote ,
165
+ TransactionInterface $ transaction ,
166
+ Log $ logger ,
167
+ Factory $ configProviderFactory ,
168
+ OrderSender $ orderSender ,
169
+ OrderStatusFactory $ orderStatusFactory ,
170
+ Session $ checkoutSession ,
171
+ CustomerSession $ customerSession ,
173
172
CustomerRepositoryInterface $ customerRepository ,
174
- SessionFactory $ sessionFactory ,
175
- Customer $ customerModel ,
176
- CustomerFactory $ customerFactory ,
177
- OrderService $ orderService ,
178
- ManagerInterface $ eventManager ,
179
- Recreate $ quoteRecreate ,
180
- LockManagerWrapper $ lockManager
181
- ) {
173
+ SessionFactory $ sessionFactory ,
174
+ Customer $ customerModel ,
175
+ CustomerFactory $ customerFactory ,
176
+ OrderService $ orderService ,
177
+ ManagerInterface $ eventManager ,
178
+ Recreate $ quoteRecreate ,
179
+ LockManagerWrapper $ lockManager
180
+ )
181
+ {
182
182
parent ::__construct ($ context );
183
- $ this ->helper = $ helper ;
184
- $ this ->cart = $ cart ;
185
- $ this ->order = $ order ;
186
- $ this ->quote = $ quote ;
187
- $ this ->transaction = $ transaction ;
188
- $ this ->logger = $ logger ;
189
- $ this ->orderSender = $ orderSender ;
183
+ $ this ->helper = $ helper ;
184
+ $ this ->cart = $ cart ;
185
+ $ this ->order = $ order ;
186
+ $ this ->quote = $ quote ;
187
+ $ this ->transaction = $ transaction ;
188
+ $ this ->logger = $ logger ;
189
+ $ this ->orderSender = $ orderSender ;
190
190
$ this ->orderStatusFactory = $ orderStatusFactory ;
191
- $ this ->checkoutSession = $ checkoutSession ;
192
- $ this ->customerSession = $ customerSession ;
191
+ $ this ->checkoutSession = $ checkoutSession ;
192
+ $ this ->customerSession = $ customerSession ;
193
193
$ this ->customerRepository = $ customerRepository ;
194
- $ this ->_sessionFactory = $ sessionFactory ;
194
+ $ this ->_sessionFactory = $ sessionFactory ;
195
195
196
- $ this ->customerModel = $ customerModel ;
196
+ $ this ->customerModel = $ customerModel ;
197
197
$ this ->customerResourceFactory = $ customerFactory ;
198
198
199
199
$ this ->accountConfig = $ configProviderFactory ->get ('account ' );
@@ -261,7 +261,8 @@ public function execute()
261
261
* @throws LocalizedException
262
262
* @throws \Exception
263
263
*/
264
- private function redirectProcess () {
264
+ private function redirectProcess ()
265
+ {
265
266
/**
266
267
* Check if there is a valid response. If not, redirect to home.
267
268
*/
@@ -408,22 +409,23 @@ private function redirectProcess() {
408
409
$ this ->order ->getIncrementId (),
409
410
], true ));
410
411
411
- if (!$ this ->checkoutSession ->getLastSuccessQuoteId () && $ this ->order ->getQuoteId ()) {
412
- $ this ->logger ->addDebug (__METHOD__ . '|52| ' );
413
- $ this ->checkoutSession ->setLastSuccessQuoteId ($ this ->order ->getQuoteId ());
412
+ if ($ this ->order && $ this ->order ->getId ()) {
413
+ $ this ->checkoutSession ->setLastOrderId ($ this ->order ->getId ());
414
414
}
415
- if (! $ this -> checkoutSession -> getLastQuoteId () && $ this -> order -> getQuoteId ()) {
416
- $ this ->logger -> addDebug ( __METHOD__ . ' |53| ' );
415
+
416
+ if ( $ this -> order && $ this ->order -> getQuoteId ()) {
417
417
$ this ->checkoutSession ->setLastQuoteId ($ this ->order ->getQuoteId ());
418
+ $ this ->checkoutSession ->setLastSuccessQuoteId ($ this ->order ->getQuoteId ());
418
419
}
419
- if (!$ this ->checkoutSession ->getLastOrderId () && $ this ->order ->getId ()) {
420
- $ this ->logger ->addDebug (__METHOD__ . '|54| ' );
421
- $ this ->checkoutSession ->setLastOrderId ($ this ->order ->getId ());
422
- }
423
- if (!$ this ->checkoutSession ->getLastRealOrderId () && $ this ->order ->getIncrementId ()) {
424
- $ this ->logger ->addDebug (__METHOD__ . '|55| ' );
420
+
421
+ if ($ this ->order && $ this ->order ->getIncrementId ()) {
425
422
$ this ->checkoutSession ->setLastRealOrderId ($ this ->order ->getIncrementId ());
426
423
}
424
+
425
+ if ($ this ->order && $ this ->order ->getStatus ()) {
426
+ $ this ->checkoutSession ->setLastOrderStatus ($ this ->order ->getStatus ());
427
+ }
428
+
427
429
$ this ->logger ->addDebug (__METHOD__ . '|6| ' );
428
430
return $ this ->redirectSuccess ();
429
431
case $ this ->helper ->getStatusCode ('BUCKAROO_MAGENTO2_ORDER_FAILED ' ):
@@ -436,6 +438,7 @@ private function redirectProcess() {
436
438
return $ this ->handleProcessedResponse ('/ ' );
437
439
}
438
440
}
441
+
439
442
/**
440
443
* Handle final response
441
444
*
@@ -449,6 +452,7 @@ public function handleProcessedResponse($path, $arguments = [])
449
452
$ this ->logger ->addDebug (__METHOD__ . '|15| ' );
450
453
return $ this ->_redirect ($ path , $ arguments );
451
454
}
455
+
452
456
/**
453
457
* Get order
454
458
*
@@ -458,6 +462,7 @@ public function getOrder()
458
462
{
459
463
return $ this ->order ;
460
464
}
465
+
461
466
/**
462
467
* Add error message to be displayed to the user
463
468
*
@@ -469,6 +474,7 @@ public function addErrorMessage(string $message)
469
474
{
470
475
$ this ->messageManager ->addErrorMessage ($ message );
471
476
}
477
+
472
478
/**
473
479
* Add success message to be displayed to the user
474
480
*
@@ -492,8 +498,8 @@ public function addSuccessMessage(string $message)
492
498
protected function setPaymentOutOfTransit (OrderPaymentInterface $ payment )
493
499
{
494
500
$ payment
495
- ->setAdditionalInformation (AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT , false )
496
- ->save ();
501
+ ->setAdditionalInformation (AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT , false )
502
+ ->save ();
497
503
}
498
504
499
505
/**
@@ -805,7 +811,7 @@ public function getSkipHandleFailedRecreate()
805
811
*/
806
812
protected function removeCoupon ()
807
813
{
808
- if (method_exists ($ this ->order ,'getCouponCode ' )) {
814
+ if (method_exists ($ this ->order , 'getCouponCode ' )) {
809
815
$ couponCode = $ this ->order ->getCouponCode ();
810
816
$ couponFactory = $ this ->_objectManager ->get (CouponFactory::class);
811
817
if (!(is_object ($ couponFactory ) && method_exists ($ couponFactory , 'load ' ))) {
@@ -818,7 +824,7 @@ protected function removeCoupon()
818
824
return ;
819
825
}
820
826
821
- if (is_int ($ coupon ->getCouponId ())) {
827
+ if ($ coupon && is_int ($ coupon ->getCouponId ())) {
822
828
$ resourceModel ->delete ($ coupon );
823
829
}
824
830
}
0 commit comments