Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PW-3546] Adding payload and redirectResult GET parameters to transparent redirect #92

Merged
merged 3 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions Controllers/Frontend/Transparent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class Shopware_Controllers_Frontend_Transparent extends Shopware_Controllers_Frontend_Payment implements CSRFWhitelistAware
{

const ALLOWED_PARAMS = ['MD', 'PaRes'];
/**
* @var Logger
*/
Expand All @@ -29,30 +30,34 @@ public function getWhitelistedCSRFActions()
*/
public function redirectAction()
{
$allowedPostParams = ['MD', 'PaRes'];
$redirectUrl = Shopware()->Router()->assemble([
'controller' => 'process',
'action' => 'return',
]);

$this->View()->assign('redirectUrl', $redirectUrl);
$this->View()->assign('postParams', $this->retrievePostParams($allowedPostParams));
$this->View()->assign('redirectParams', $this->retrieveParams());
$this->logger->debug('Forward incoming POST response to process/return', [
'POST parameter keys' => $allowedPostParams
'POST and GET parameter keys' => self::ALLOWED_PARAMS
]);
}

private function retrievePostParams(array $allowedParams): array
private function retrieveParams(): array
{
$params = [];
foreach ($allowedParams as $key) {
if (null === $value = $this->Request()->getPost($key)) {
continue;
$request = $this->Request();

//Getting all GET parameters except for Shopware's action, controller and module
$getParams = $request->getQuery();
unset($getParams['action'], $getParams['controller'], $getParams['module']);

//Filtering allowed POST parameters
$fullPostParams = $request->getParams();
$postParams = [];
foreach (self::ALLOWED_PARAMS as $allowedParam) {
if (isset($fullPostParams[$allowedParam])) {
$postParams[$allowedParam] = $fullPostParams[$allowedParam];
}

$params[$key] = $value;
}

return $params;
return array_merge($getParams, $postParams);
cyattilakiss marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 2 additions & 2 deletions Resources/views/frontend/transparent/redirect.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<head><title></title></head>
<body onload="document.forms['transparent_redirect'].submit();">
<form id="transparent_redirect" method="POST" action="{$redirectUrl}">
{foreach $postParams as $value}
{foreach $redirectParams as $value}
<input type="hidden" name="{$value@key}" value="{$value|escape}" />
{/foreach}
</form>
</body>
</html>
{/strip}
{/block}
{/block}