11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2020 Adobe
4+ * All rights reserved .
55 */
66namespace Magento \Paypal \Controller \Transparent ;
77
88use Magento \Framework \App \Action \Action ;
99use Magento \Framework \App \Action \Context ;
10+ use Magento \Framework \App \Action \HttpGetActionInterface ;
1011use Magento \Framework \App \Action \HttpPostActionInterface ;
1112use Magento \Framework \App \CsrfAwareActionInterface ;
1213use Magento \Framework \App \Request \InvalidRequestException ;
2021/**
2122 * Class for redirecting the Paypal response result to Magento controller.
2223 */
23- class Redirect extends Action implements CsrfAwareActionInterface, HttpPostActionInterface
24+ class Redirect extends Action implements CsrfAwareActionInterface, HttpPostActionInterface, HttpGetActionInterface
2425{
2526 /**
2627 * @var LayoutFactory
@@ -81,6 +82,7 @@ public function validateForCsrf(RequestInterface $request): ?bool
8182 */
8283 public function execute ()
8384 {
85+ $ this ->mapGatewayResponse ();
8486 $ gatewayResponse = (array )$ this ->getRequest ()->getPostValue ();
8587 $ this ->logger ->debug (
8688 ['PayPal PayflowPro redirect: ' => $ gatewayResponse ],
@@ -94,4 +96,20 @@ public function execute()
9496
9597 return $ resultLayout ;
9698 }
99+
100+ /**
101+ * Fill post data with gateway response params
102+ *
103+ * @return void
104+ */
105+ private function mapGatewayResponse (): void
106+ {
107+ if (!empty ($ this ->getRequest ()->getPostValue ())) {
108+ return ;
109+ }
110+ $ gatewayResponse = $ this ->getRequest ()->getParams ();
111+ if (!empty ($ gatewayResponse )) {
112+ $ this ->getRequest ()->setPostValue ($ gatewayResponse );
113+ }
114+ }
97115}
0 commit comments