<?php

namespace Sipago\WooCommerce\SipagoCheckout\Helpers;

class RedirectorHelper
{

    public static function getRedirectForm($url, array $data)
    {
        $msg = "<form action='".$url."' method='POST' name='sipagopayForm'>";
        foreach ($data as $name => $value) {
            $msg .= "<input type='hidden' name='".htmlentities($name)."' value='".htmlentities($value)."'>";
        }
        $msg .= '</form>'.'<script>'.'document.sipagopayForm.submit();'.'</script>';

        return $msg;
    }

    public static function redirect($url, array $data)
    {
        echo static::getRedirectForm($url, $data);
    }
}
