Skip to content

Commit 283a9ff

Browse files
Merge pull request #1121 from buckaroo-it/BP-3830-Paylink-order-from-secondary-store-view-is-not-updated-to-processing
BP-3830-Paylink-order-from-secondary-store-view-is-not-updated-to-processing
2 parents 06f78ac + 811e128 commit 283a9ff

File tree

1 file changed

+63
-57
lines changed

1 file changed

+63
-57
lines changed

Controller/Redirect/Process.php

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -144,56 +144,56 @@ class Process extends Action
144144
* @param Factory $configProviderFactory
145145
* @param OrderSender $orderSender
146146
* @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
156156
* @param LockManagerWrapper $lockManager
157-
*
158157
* @throws Exception
159158
*/
160159
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,
173172
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+
{
182182
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;
190190
$this->orderStatusFactory = $orderStatusFactory;
191-
$this->checkoutSession = $checkoutSession;
192-
$this->customerSession = $customerSession;
191+
$this->checkoutSession = $checkoutSession;
192+
$this->customerSession = $customerSession;
193193
$this->customerRepository = $customerRepository;
194-
$this->_sessionFactory = $sessionFactory;
194+
$this->_sessionFactory = $sessionFactory;
195195

196-
$this->customerModel = $customerModel;
196+
$this->customerModel = $customerModel;
197197
$this->customerResourceFactory = $customerFactory;
198198

199199
$this->accountConfig = $configProviderFactory->get('account');
@@ -261,7 +261,8 @@ public function execute()
261261
* @throws LocalizedException
262262
* @throws \Exception
263263
*/
264-
private function redirectProcess() {
264+
private function redirectProcess()
265+
{
265266
/**
266267
* Check if there is a valid response. If not, redirect to home.
267268
*/
@@ -408,22 +409,23 @@ private function redirectProcess() {
408409
$this->order->getIncrementId(),
409410
], true));
410411

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());
414414
}
415-
if (!$this->checkoutSession->getLastQuoteId() && $this->order->getQuoteId()) {
416-
$this->logger->addDebug(__METHOD__ . '|53|');
415+
416+
if ($this->order && $this->order->getQuoteId()) {
417417
$this->checkoutSession->setLastQuoteId($this->order->getQuoteId());
418+
$this->checkoutSession->setLastSuccessQuoteId($this->order->getQuoteId());
418419
}
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()) {
425422
$this->checkoutSession->setLastRealOrderId($this->order->getIncrementId());
426423
}
424+
425+
if ($this->order && $this->order->getStatus()) {
426+
$this->checkoutSession->setLastOrderStatus($this->order->getStatus());
427+
}
428+
427429
$this->logger->addDebug(__METHOD__ . '|6|');
428430
return $this->redirectSuccess();
429431
case $this->helper->getStatusCode('BUCKAROO_MAGENTO2_ORDER_FAILED'):
@@ -436,6 +438,7 @@ private function redirectProcess() {
436438
return $this->handleProcessedResponse('/');
437439
}
438440
}
441+
439442
/**
440443
* Handle final response
441444
*
@@ -449,6 +452,7 @@ public function handleProcessedResponse($path, $arguments = [])
449452
$this->logger->addDebug(__METHOD__ . '|15|');
450453
return $this->_redirect($path, $arguments);
451454
}
455+
452456
/**
453457
* Get order
454458
*
@@ -458,6 +462,7 @@ public function getOrder()
458462
{
459463
return $this->order;
460464
}
465+
461466
/**
462467
* Add error message to be displayed to the user
463468
*
@@ -469,6 +474,7 @@ public function addErrorMessage(string $message)
469474
{
470475
$this->messageManager->addErrorMessage($message);
471476
}
477+
472478
/**
473479
* Add success message to be displayed to the user
474480
*
@@ -492,8 +498,8 @@ public function addSuccessMessage(string $message)
492498
protected function setPaymentOutOfTransit(OrderPaymentInterface $payment)
493499
{
494500
$payment
495-
->setAdditionalInformation(AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT, false)
496-
->save();
501+
->setAdditionalInformation(AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT, false)
502+
->save();
497503
}
498504

499505
/**
@@ -805,7 +811,7 @@ public function getSkipHandleFailedRecreate()
805811
*/
806812
protected function removeCoupon()
807813
{
808-
if (method_exists($this->order,'getCouponCode')) {
814+
if (method_exists($this->order, 'getCouponCode')) {
809815
$couponCode = $this->order->getCouponCode();
810816
$couponFactory = $this->_objectManager->get(CouponFactory::class);
811817
if (!(is_object($couponFactory) && method_exists($couponFactory, 'load'))) {
@@ -818,7 +824,7 @@ protected function removeCoupon()
818824
return;
819825
}
820826

821-
if (is_int($coupon->getCouponId())) {
827+
if ($coupon && is_int($coupon->getCouponId())) {
822828
$resourceModel->delete($coupon);
823829
}
824830
}

0 commit comments

Comments
 (0)