plugins – redirect payment gateway

Question

I would like if redirect.php is working? Shall I place the redirect.php in sample plugin folder?

content of redirect.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
        
    <form id="redirectForm" action="https://gateway.mytmoney.mu/web/payments" method="post">
        <input type="hidden" name="appId" value="<?php echo $_GET[ 'appID' ]; ?>"/>
        <input type="hidden" name="merTradeNo" value="<?php echo $_GET[ 'merTradeNo' ]; ?>"/>
        <input type="hidden" name="payload" value="<?php echo $_GET[ 'encryptedPayload' ]; ?>"/> 
        <input type="hidden" name="paymentType" value="<?php echo $_GET[ 'paymentType' ]; ?>"/>
        <input type="hidden" name="sign" value="<?php echo $_GET[ 'sign' ]; ?>"/>
        <p><input type="submit" value="Pay By my.t money"/></p>
        </form>

<form action="https://transaportation.local/my-account" method="post">
        <input type="hidden" name="merTradeNo" value=MT001/>
        <input type="hidden" name="TradeNo" value="123456"/>
        <input type="hidden" name="tradeStatus" value="S"/>
        <input type="hidden" name="msg" value="SUCCESS"/>
        <input type="hidden" name="resultcode" value="000"/>
        <input type="hidden" name="sign" value=""/>
        </form>
<script type="text/javascript">
    document.all.redirectForm.submit();
</script>   
</body>
</html>

Content of plugin:
public function process_payment( $order_id ) {
….
//initiate payment
$response = $moovpay->purchase($appID,$merTradeNo,$encryptedPayload,$paymentType,$sign);
$fh = fopen(plugin_dir_path(FILE).’redirect.php’, ‘w+’);
fwrite($fh, $response);
fclose($fh);
$redirect_url = plugin_dir_url(FILE).’redirect.php’;

        return array(
        'result' => 'success',
        'redirect' => $redirect_url
        );

Thanks,

Roshan

0
Roshan DiMateo 1 month 2022-07-04T19:28:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse