【发布时间】:2019-11-29 12:17:05
【问题描述】:
我想向银行网关https://pep.shaparak.ir/gateway.aspx 发送一个发布请求。存在的示例代码是:
<center>Please Wait...</center>
<div style="display:none">
<form name='myform' method='post' action='https://pep.shaparak.ir/gateway.aspx'>
<input type='text' name='terminal' value='<?=$terminalCode?>' />
<input type='text' name='merchant' value='<?=$merchantCode?>' />
.
.
.
</form>
</div>
<script>document.myform.submit()</script>
用户重定向到银行想要的页面..但是我猜它存在安全问题,不是吗?因为用户可以返回到上一页并查看输入中的内容,这些输入是银行请求的凭据。 所以我一直在尝试使用 curl 并用它发送数据:
$postFields = [
'terminalCode' => $terminalCode,
'merchantCode' => $merchantCode,
.
.
.
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pep.shaparak.ir/gateway.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, count($postFields));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if(isset($info['url'])) {
// Because I'm using Laravel.
return redirect()->to($info['url']);
}
但现在的问题是它不会自动重定向到银行想要的页面。
如何将用户重定向到银行退货页面?
【问题讨论】:
-
请求成功后API返回什么?
-
你能添加一个链接到它的文档吗?
-
$info['url']的值为https://pep.shaparak.ir/payment.aspx?n=KkLLrzcvjsGxZHdBOKpK2AE8NGPVF8+SqexHYdRG8CE=&Language=Fa,n参数可以是其他任何值。它重定向到银行,但银行的响应是:购买的时间限制已结束。顺便说一句,我在本地做,这可能是问题吗? -
文档为波斯语。你会读波斯语吗?
标签: php payment-gateway form-submit php-curl