我们使用WorldPay来处理分层成员系统的支付,支付金额取决于所选的成员级别。
付款通过来自多个隐藏字段的表单post传递给WorldPay,包括:
<input type="hidden" name="amount" value="295.00" />从本质上说,表单是通过POST提交给WorldPay的,用户按照一系列步骤处理他们的付款。一旦完成,用户将被重定向到指定的确认页。
这似乎是WorldPay接受付款的典型方式。这里有一个明显的问题,隐藏字段的值很容易被任何具有HTML基础知识的人篡改。该表单直接发布到WorldPay,因此我们没有可以根据成员级别验证金额的PostBack。
当付款通知从WorldPay返回给我们时,我们可以通过确认页面前的处理程序来验证付款金额;但是,我希望避免出现这样的情况:用户提交被篡改的表单,支付不正确的金额,并且没有收到任何成员资格,然后必须与公司联系才能退还他们的钱。
在处理付款之前,我们如何验证所提交的金额是否正确?
更新
我意识到,我们还有一个额外的问题,即使我们验证表单post服务器端,也没有什么能阻止恶意用户直接欺骗表单帖子到WorldPay。
发布于 2013-03-27 19:17:55
实际上,它是一个漏洞,可以很容易地使用签名解决。请查看以下链接:
http://culttt.com/2012/07/25/integrating-worldpay-into-a-database-driven-website/
这个方法应该在“帮助”页面上得到更好的推广,这太糟糕了。
发布于 2013-03-21 10:27:10
我能想到的一个解决方案是,捕获form标记的submit
<form id="myForm" onsubmit="return validatePayment();">然后创建JavaScript文件,如下所示:
var isValidAmount = false;
function validatePayment() {
if (isValidAmount) { return true; }
// in here you want to issue an AJAX call back to your server
// with the appropriate information ... I would recommend using
// jQuery and so it might look something like this:
$.ajax( {
type: "POST",
url: url,
data: { amount: $("#amount").val(), someotherfield: somevalue },
success: function(data, textStatus, jqXHR) {
// set the flag so that it can succeed the next time through
isValidAmount = true;
// resubmit the form ... it will reenter this function but leave
// immediately returning true so the submit will actually occur
$("myForm").submit();
},
});
// this will keep the form from actually submitting the first time
return false;
}https://stackoverflow.com/questions/15544633
复制相似问题