Skip to content

Commit e54deaa

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-39685' into MAGETWO-32996
2 parents d5eb1be + 64e94a9 commit e54deaa

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

app/code/Magento/Paypal/Controller/Payflow/ReturnUrl.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ public function execute()
3434
/** @var \Magento\Sales\Model\Order $order */
3535
$order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
3636

37-
if (in_array($order->getState(), $this->allowedOrderStates)) {
38-
$redirectBlock->setData('goto_success_page', true);
39-
} else {
40-
$gotoSection = $this->_cancelPayment(strval($this->getRequest()->getParam('RESPMSG')));
41-
$redirectBlock->setData('goto_section', $gotoSection);
42-
$redirectBlock->setData('error_msg', __('Your payment has been declined. Please try again.'));
37+
if ($order->getIncrementId()) {
38+
if (in_array($order->getState(), $this->allowedOrderStates)) {
39+
$redirectBlock->setData('goto_success_page', true);
40+
} else {
41+
$gotoSection = $this->_cancelPayment(strval($this->getRequest()->getParam('RESPMSG')));
42+
$redirectBlock->setData('goto_section', $gotoSection);
43+
$redirectBlock->setData('error_msg', __('Your payment has been declined. Please try again.'));
44+
}
4345
}
4446
}
4547

app/code/Magento/Paypal/Test/Unit/Controller/Payflow/ReturnUrlTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ public function testExecuteAllowedOrderState($state)
181181
->with($lastRealOrderId)
182182
->will($this->returnSelf());
183183

184+
$this->orderMock
185+
->expects($this->once())
186+
->method('getIncrementId')
187+
->will($this->returnValue($lastRealOrderId));
188+
184189
$this->orderMock
185190
->expects($this->once())
186191
->method('getState')
@@ -240,6 +245,11 @@ public function testExecuteNotAllowedOrderState($state, $restoreQuote, $expected
240245
->with($lastRealOrderId)
241246
->will($this->returnSelf());
242247

248+
$this->orderMock
249+
->expects($this->once())
250+
->method('getIncrementId')
251+
->will($this->returnValue($lastRealOrderId));
252+
243253
$this->orderMock
244254
->expects($this->once())
245255
->method('getState')

0 commit comments

Comments
 (0)