<?php

$data = $block->getData();
$url = $data['gatewayURL'];
$request = $data['requestFields'];

echo '<form id="silentPost" action="' . $url . '" method="post" target="paymentgatewayframe">';
foreach ($request as $field => $value) {
    if (is_array($value)) {
        foreach ($value as $nestedField => $nestedFieldValue) {
            echo '<input type="hidden" name="' . $field . '[' . $nestedField .']' . '" value="' .
            htmlentities($nestedFieldValue) . '">' . PHP_EOL;
        }
    } else {
        echo '<input type="hidden" name="' . $field . '" value="' . htmlentities($value) . '">' . PHP_EOL;
    }
}
echo '</form>';
echo '<iframe id="paymentgatewayframe" name="paymentgatewayframe" frameBorder="0" seamless="seamless" style="width: 100%; height: 1200px; margin: 0 auto; display: block;"></iframe>';

$scriptString = <<<SCRIPT
window.setTimeout("document.forms.silentPost.submit()", 0);
SCRIPT;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', ['type' => 'text/javascript'], $scriptString, false); ?>
