我目前有一个大表格发送给我们的付款授权人(通过 action="paymentautherizerURL" 完成),但是当我将交易存储在我的数据库中时,我没有从他们那里得到我需要的所有信息。
我要么需要在提交之前拦截表单数据,以便我可以将其存储在会话中(我们使用的是 PHP / jQuery),要么我也尝试将其发送到获取我需要的信息的中间小脚本,然后使用jQuery 的 $.post() 重新构建并将数据发送给授权者。
然而,第二种方法似乎并不奏效,至少在我的努力下是这样。我不确定 $.post 是否正确模拟了表单的发送操作,或者至少我做得不对。
<?php
session_start();
$post = $_POST;
//gets all of the information that beanstream does not return to approved.php, but is still required to make
//a legitimate database entry. gets from the POST and stores in the session array for approved.PHP to access
$_SESSION['approvedArray']['billAddress'] = $_POST['ordAddress1'];
$_SESSION['approvedArray']['billProvince'] = $_POST['ordProvince'];
$_SESSION['approvedArray']['billCountry'] = $_POST['ordCountry'];
$_SESSION['approvedArray']['billPostalCode'] = $_POST['ordPostalCode'];
$_SESSION['approvedArray']['billCity'] = $_POST['ordCity'];
$_SESSION['approvedArray']['shipAddress'] = $_POST['shipAddress1'];
$_SESSION['approvedArray']['shipPostal'] = $_POST['shipPostalCode'];
$_SESSION['approvedArray']['shipCity'] = $_POST['shipCity'];
$_SESSION['approvedArray']['shipProvince'] = $_POST['shipProvince'];
$_SESSION['approvedArray']['shipCountry'] = $_POST['shipCountry'];
session_write_close();
//the javascript below will send what is required to beanstream as though it were sent from the form
<script type='text/javascript'>
$.post(, {
<?php
//rebuild the POST such that "name: value, " except the last name/value will not be followed by a comma
$keys = array_keys($_POST);
for($i = 0; $i < count($_POST); $i++) {
$currentKey = $keys[$i];
$currentPost = $_POST[i];
echo $currentKey . ": " . $currentPost;
if ($i < (count($_POST) - 1)) {
echo ", ";
}
}
?>
});
</script>
?>
通常,交易授权人会将用户重定向到 3 个页面之一(已批准、已拒绝、错误),我们的网站会从那里完成这项工作。但是,它目前停留在此页面,这让我觉得它没有正确发送。
我对各种形式的批评、方法和想法持开放态度。提前非常感谢,如果需要任何其他信息,请告诉我!