Skip to content

Commit 9497ac1

Browse files
committed
Merge remote-tracking branch 'origin/MC-32546' into 2.4-develop-pr20
2 parents 52d3813 + 91580a4 commit 9497ac1

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

app/code/Magento/Paypal/Controller/Hostedpro/Cancel.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Paypal\Controller\Hostedpro;
89

10+
use Magento\Framework\App\Action\Action;
911
use Magento\Framework\App\Action\Context;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
use Magento\Framework\App\CsrfAwareActionInterface;
14+
use Magento\Framework\App\Request\InvalidRequestException;
15+
use Magento\Framework\App\RequestInterface;
1016
use Magento\Paypal\Helper\Checkout;
1117

12-
class Cancel extends \Magento\Framework\App\Action\Action
18+
/**
19+
* PayPal Hostedpro cancel controller.
20+
*/
21+
class Cancel extends Action implements CsrfAwareActionInterface, HttpGetActionInterface
1322
{
1423
/**
1524
* @var Checkout
@@ -40,4 +49,20 @@ public function execute()
4049

4150
$this->_redirect('checkout', ['_fragment' => 'payment']);
4251
}
52+
53+
/**
54+
* @inheritDoc
55+
*/
56+
public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
57+
{
58+
return null;
59+
}
60+
61+
/**
62+
* @inheritDoc
63+
*/
64+
public function validateForCsrf(RequestInterface $request): ?bool
65+
{
66+
return true;
67+
}
4368
}

app/code/Magento/Paypal/Controller/Hostedpro/ReturnAction.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Paypal\Controller\Hostedpro;
89

9-
class ReturnAction extends \Magento\Framework\App\Action\Action
10+
use Magento\Framework\App\Action\Action;
11+
use Magento\Framework\App\Action\HttpGetActionInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
13+
use Magento\Framework\App\CsrfAwareActionInterface;
14+
use Magento\Framework\App\Request\InvalidRequestException;
15+
use Magento\Framework\App\RequestInterface;
16+
17+
/**
18+
* PayPal Hostedpro return controller.
19+
*/
20+
class ReturnAction extends Action implements CsrfAwareActionInterface, HttpPostActionInterface, HttpGetActionInterface
1021
{
1122
/**
1223
* When a customer return to website from gateway.
@@ -21,4 +32,20 @@ public function execute()
2132
$this->_redirect('checkout/onepage/success');
2233
}
2334
}
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
40+
{
41+
return null;
42+
}
43+
44+
/**
45+
* @inheritDoc
46+
*/
47+
public function validateForCsrf(RequestInterface $request): ?bool
48+
{
49+
return true;
50+
}
2451
}

app/code/Magento/Paypal/Model/Ipn.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Exception;
1010
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Sales\Model\Order;
1112
use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender;
1213
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
1314

@@ -301,6 +302,9 @@ protected function _registerPaymentCapture($skipFraudDetection = false)
301302
$payment->setParentTransactionId($parentTransactionId);
302303
$payment->setShouldCloseParentTransaction('Completed' === $this->getRequestData('auth_status'));
303304
$payment->setIsTransactionClosed(0);
305+
if ($this->_order->getState() === Order::STATE_PENDING_PAYMENT) {
306+
$this->_order->setState(Order::STATE_PROCESSING);
307+
}
304308
$payment->registerCaptureNotification(
305309
$this->getRequestData('mc_gross'),
306310
$skipFraudDetection && $parentTransactionId

app/code/Magento/Paypal/Test/Unit/Model/IpnTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected function setUp()
5353
'getEmailSent',
5454
'save',
5555
'getState',
56+
'setState',
5657
];
5758
$this->_orderMock = $this->createPartialMock(\Magento\Sales\Model\OrderFactory::class, $methods);
5859
$this->_orderMock->expects($this->any())->method('create')->will($this->returnSelf());
@@ -149,9 +150,12 @@ public function testPaymentReviewRegisterPaymentFraud()
149150
->will($this->returnValue(true));
150151
$this->_orderMock->expects($this->any())->method('getPayment')->will($this->returnValue($paymentMock));
151152
$this->_orderMock->expects($this->any())->method('canFetchPaymentReviewUpdate')->will($this->returnValue(true));
152-
$this->_orderMock->expects($this->once())->method('getState')->will(
153+
$this->_orderMock->expects($this->any())->method('getState')->will(
153154
$this->returnValue(Order::STATE_PENDING_PAYMENT)
154155
);
156+
$this->_orderMock->expects($this->once())
157+
->method('setState')
158+
->with(Order::STATE_PROCESSING);
155159
$this->_paypalInfo->expects($this->once())
156160
->method('importToPayment')
157161
->with(

0 commit comments

Comments
 (0)