我正在开发一个PHP
链接到的应用程序Protx VSP Direct payment gateway
.要处理来自信用卡处理公司的"3D安全"请求,我需要将用户转发到其他网站,模仿已发布的表单.我正在尝试使用这些cURL
库,但似乎遇到了问题.我的代码如下:
<?php
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/');
// Perform a POST
curl_setopt($ch, CURLOPT_POST, 1);
// If not set, curl prints output to the browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
// Set the "form fields"
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($ch);
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
所有这一切都是抓取传递的URL的内容,而不是将用户转发到任何地方.我尽可能多地尝试谷歌搜索和阅读,但无法弄清楚我错过了什么.有任何想法吗?我不想创建一个自动提交自己的HTML表单,如果我可以避免它.
谢谢你的帮助 :-)
3D Secure API 不允许您在后台执行请求。您需要将用户转发到 3D 安全站点。使用 javascript 自动提交您的表单。以下是我们的提供商的建议:
<html>
<head>
<title>Processing your request...</title>
</head>
<body OnLoad="OnLoadEvent();">
<form name="downloadForm" action="<%=RedirURL%>" method="POST">
<noscript>
<br>
<br>
<div align="center">
<h1>Processing your 3-D Secure Transaction</h1>
<h2>JavaScript is currently disabled or is not supported by your browser.</h2><BR>
<h3>Please click Submit to continue the processing of your 3-D Secure transaction.</h3><BR>
<input type="submit" value="Submit">
</div>
</noscript>
<input type="hidden" name="PaReq" value="<%=PAREQ%>">
<input type="hidden" name="MD" value="<%=TransactionID%>">
<input type="hidden" name="TermUrl" value="<%=TermUrl%>">
</form>
<SCRIPT LANGUAGE="Javascript">
<!--
function OnLoadEvent() {
document.downloadForm.submit();
}
//-->
</SCRIPT>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)