diff -Nuar a/vendor/magento/module-payment/Block/Transparent/Redirect.php b/vendor/magento/module-payment/Block/Transparent/Redirect.php new file mode 100644 index 00000000000..aeaeee7e4d2 --- /dev/null +++ b/vendor/magento/module-payment/Block/Transparent/Redirect.php @@ -0,0 +1,60 @@ +url = $url; + parent::__construct($context, $data); + } + + /** + * Returns url for redirect. + * + * @return string + */ + public function getRedirectUrl(): string + { + return $this->url->getUrl($this->getData(self::ROUTE_PATH)); + } + + /** + * Returns params to be redirected. + * + * @return array + */ + public function getPostParams(): array + { + return (array)$this->_request->getPostValue(); + } +} diff -Nuar a/vendor/magento/module-payment/view/adminhtml/templates/transparent/redirect.phtml b/vendor/magento/module-payment/view/adminhtml/templates/transparent/redirect.phtml new file mode 100644 index 00000000000..17fbdf780a4 --- /dev/null +++ b/vendor/magento/module-payment/view/adminhtml/templates/transparent/redirect.phtml @@ -0,0 +1,21 @@ +getPostParams(); +$redirectUrl = $block->getRedirectUrl(); +?> + + + + + + diff -Nuar a/vendor/magento/module-payment/view/frontend/templates/transparent/redirect.phtml b/vendor/magento/module-payment/view/frontend/templates/transparent/redirect.phtml new file mode 100644 index 00000000000..17fbdf780a4 --- /dev/null +++ b/vendor/magento/module-payment/view/frontend/templates/transparent/redirect.phtml @@ -0,0 +1,21 @@ +getPostParams(); +$redirectUrl = $block->getRedirectUrl(); +?> + + + + + + diff -Nuar a/vendor/magento/module-paypal/Controller/Adminhtml/Transparent/Redirect.php b/vendor/magento/module-paypal/Controller/Adminhtml/Transparent/Redirect.php new file mode 100644 index 00000000000..8201761cc3a --- /dev/null +++ b/vendor/magento/module-paypal/Controller/Adminhtml/Transparent/Redirect.php @@ -0,0 +1,13 @@ +resultLayoutFactory = $resultLayoutFactory; + $this->transparent = $transparent; + $this->logger = $logger; + + parent::__construct($context); + } + + /** + * @inheritDoc + */ + public function createCsrfValidationException( + RequestInterface $request + ): ?InvalidRequestException { + return null; + } + + /** + * @inheritDoc + */ + public function validateForCsrf(RequestInterface $request): ?bool + { + return true; + } + + /** + * Saves the payment in quote + * + * @return ResultInterface + * @throws LocalizedException + */ + public function execute() + { + $gatewayResponse = (array)$this->getRequest()->getPostValue(); + $this->logger->debug( + ['PayPal PayflowPro redirect:' => $gatewayResponse], + $this->transparent->getDebugReplacePrivateDataKeys(), + $this->transparent->getDebugFlag() + ); + + $resultLayout = $this->resultLayoutFactory->create(); + $resultLayout->addDefaultHandle(); + $resultLayout->getLayout()->getUpdate()->load(['transparent_payment_redirect']); + + return $resultLayout; + } +} diff -Nuar a/vendor/magento/module-paypal/Model/Payflow/Service/Request/SecureToken.php b/vendor/magento/module-paypal/Model/Payflow/Service/Request/SecureToken.php index 2a4ec764c41..6e9990f65c4 100644 --- a/vendor/magento/module-paypal/Model/Payflow/Service/Request/SecureToken.php +++ b/vendor/magento/module-paypal/Model/Payflow/Service/Request/SecureToken.php @@ -70,9 +70,9 @@ class SecureToken $request->setCurrency($quote->getBaseCurrencyCode()); $request->setCreatesecuretoken('Y'); $request->setSecuretokenid($this->mathRandom->getUniqueHash()); - $request->setReturnurl($urls['return_url'] ?? $this->url->getUrl('paypal/transparent/response')); - $request->setErrorurl($urls['error_url'] ?? $this->url->getUrl('paypal/transparent/response')); - $request->setCancelurl($urls['cancel_url'] ?? $this->url->getUrl('paypal/transparent/response')); + $request->setReturnurl($urls['return_url'] ?? $this->url->getUrl('paypal/transparent/redirect')); + $request->setErrorurl($urls['error_url'] ?? $this->url->getUrl('paypal/transparent/redirect')); + $request->setCancelurl($urls['cancel_url'] ?? $this->url->getUrl('paypal/transparent/redirect')); $request->setDisablereceipt('TRUE'); $request->setSilenttran('TRUE'); diff -Nuar a/vendor/magento/module-paypal/Model/Payflow/Service/Response/Transaction.php b/vendor/magento/module-paypal/Model/Payflow/Service/Response/Transaction.php index 5db78e6fac5..1e97ac8b8c7 100644 --- a/vendor/magento/module-paypal/Model/Payflow/Service/Response/Transaction.php +++ b/vendor/magento/module-paypal/Model/Payflow/Service/Response/Transaction.php @@ -19,7 +19,8 @@ use Magento\Quote\Model\Quote\Payment; use Magento\Sales\Api\Data\OrderPaymentInterface; /** - * Class Transaction + * Process PayPal transaction response. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Transaction @@ -90,7 +91,7 @@ class Transaction $response = $this->transparent->mapGatewayResponse((array) $gatewayTransactionResponse, $response); $this->logger->debug( - (array) $gatewayTransactionResponse, + ['PayPal PayflowPro response:' => (array)$gatewayTransactionResponse], (array) $this->transparent->getDebugReplacePrivateDataKeys(), (bool) $this->transparent->getDebugFlag() ); diff -Nuar a/vendor/magento/module-paypal/Plugin/TransparentSessionChecker.php b/vendor/magento/module-paypal/Plugin/TransparentSessionChecker.php new file mode 100644 index 00000000000..5157ba3208f --- /dev/null +++ b/vendor/magento/module-paypal/Plugin/TransparentSessionChecker.php @@ -0,0 +1,50 @@ +request = $request; + } + + /** + * Prevents session starting while instantiating PayPal transparent redirect controller. + * + * @param SessionStartChecker $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterCheck(SessionStartChecker $subject, bool $result): bool + { + if ($result === false) { + return false; + } + + return strpos((string)$this->request->getPathInfo(), self::TRANSPARENT_REDIRECT_PATH) === false; + } +} diff -Nuar a/vendor/magento/module-paypal/etc/di.xml b/vendor/magento/module-paypal/etc/di.xml index c0141bbb321..973ed0f9192 100644 --- a/vendor/magento/module-paypal/etc/di.xml +++ b/vendor/magento/module-paypal/etc/di.xml @@ -252,4 +252,7 @@ + + + diff -Nuar a/vendor/magento/module-paypal/etc/frontend/page_types.xml b/vendor/magento/module-paypal/etc/frontend/page_types.xml index 133ab1ca761..1da5d54fb38 100644 --- a/vendor/magento/module-paypal/etc/frontend/page_types.xml +++ b/vendor/magento/module-paypal/etc/frontend/page_types.xml @@ -14,6 +14,7 @@ + diff -Nuar a/vendor/magento/module-paypal/view/adminhtml/layout/transparent_payment_redirect.xml b/vendor/magento/module-paypal/view/adminhtml/layout/transparent_payment_redirect.xml new file mode 100644 index 00000000000..01acf03c0d0 --- /dev/null +++ b/vendor/magento/module-paypal/view/adminhtml/layout/transparent_payment_redirect.xml @@ -0,0 +1,16 @@ + + + + + + + paypal/transparent/response + + + + diff -Nuar a/vendor/magento/module-paypal/view/frontend/layout/transparent_payment_redirect.xml b/vendor/magento/module-paypal/view/frontend/layout/transparent_payment_redirect.xml new file mode 100644 index 00000000000..01acf03c0d0 --- /dev/null +++ b/vendor/magento/module-paypal/view/frontend/layout/transparent_payment_redirect.xml @@ -0,0 +1,16 @@ + + + + + + + paypal/transparent/response + + + +