File tree Expand file tree Collapse file tree 4 files changed +65
-5
lines changed Expand file tree Collapse file tree 4 files changed +65
-5
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- *
4
3
* Copyright © Magento, Inc. All rights reserved.
5
4
* See COPYING.txt for license details.
6
5
*/
6
+ declare (strict_types=1 );
7
+
7
8
namespace Magento \Paypal \Controller \Hostedpro ;
8
9
10
+ use Magento \Framework \App \Action \Action ;
9
11
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 ;
10
16
use Magento \Paypal \Helper \Checkout ;
11
17
12
- class Cancel extends \Magento \Framework \App \Action \Action
18
+ /**
19
+ * PayPal Hostedpro cancel controller.
20
+ */
21
+ class Cancel extends Action implements CsrfAwareActionInterface, HttpGetActionInterface
13
22
{
14
23
/**
15
24
* @var Checkout
@@ -40,4 +49,20 @@ public function execute()
40
49
41
50
$ this ->_redirect ('checkout ' , ['_fragment ' => 'payment ' ]);
42
51
}
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
+ }
43
68
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- *
4
3
* Copyright © Magento, Inc. All rights reserved.
5
4
* See COPYING.txt for license details.
6
5
*/
6
+ declare (strict_types=1 );
7
+
7
8
namespace Magento \Paypal \Controller \Hostedpro ;
8
9
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
10
21
{
11
22
/**
12
23
* When a customer return to website from gateway.
@@ -21,4 +32,20 @@ public function execute()
21
32
$ this ->_redirect ('checkout/onepage/success ' );
22
33
}
23
34
}
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
+ }
24
51
}
Original file line number Diff line number Diff line change 8
8
9
9
use Exception ;
10
10
use Magento \Framework \Exception \LocalizedException ;
11
+ use Magento \Sales \Model \Order ;
11
12
use Magento \Sales \Model \Order \Email \Sender \CreditmemoSender ;
12
13
use Magento \Sales \Model \Order \Email \Sender \OrderSender ;
13
14
@@ -301,6 +302,9 @@ protected function _registerPaymentCapture($skipFraudDetection = false)
301
302
$ payment ->setParentTransactionId ($ parentTransactionId );
302
303
$ payment ->setShouldCloseParentTransaction ('Completed ' === $ this ->getRequestData ('auth_status ' ));
303
304
$ payment ->setIsTransactionClosed (0 );
305
+ if ($ this ->_order ->getState () === Order::STATE_PENDING_PAYMENT ) {
306
+ $ this ->_order ->setState (Order::STATE_PROCESSING );
307
+ }
304
308
$ payment ->registerCaptureNotification (
305
309
$ this ->getRequestData ('mc_gross ' ),
306
310
$ skipFraudDetection && $ parentTransactionId
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ protected function setUp()
53
53
'getEmailSent ' ,
54
54
'save ' ,
55
55
'getState ' ,
56
+ 'setState ' ,
56
57
];
57
58
$ this ->_orderMock = $ this ->createPartialMock (\Magento \Sales \Model \OrderFactory::class, $ methods );
58
59
$ this ->_orderMock ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnSelf ());
@@ -149,9 +150,12 @@ public function testPaymentReviewRegisterPaymentFraud()
149
150
->will ($ this ->returnValue (true ));
150
151
$ this ->_orderMock ->expects ($ this ->any ())->method ('getPayment ' )->will ($ this ->returnValue ($ paymentMock ));
151
152
$ 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 (
153
154
$ this ->returnValue (Order::STATE_PENDING_PAYMENT )
154
155
);
156
+ $ this ->_orderMock ->expects ($ this ->once ())
157
+ ->method ('setState ' )
158
+ ->with (Order::STATE_PROCESSING );
155
159
$ this ->_paypalInfo ->expects ($ this ->once ())
156
160
->method ('importToPayment ' )
157
161
->with (
You can’t perform that action at this time.
0 commit comments