【问题标题】:Validating payment amounts with WorldPay使用 WorldPay 验证付款金额
【发布时间】:2013-03-10 19:00:36
【问题描述】:

我们正在使用 WorldPay 处理分级会员系统的付款,该系统的付款金额取决于所选的会员等级。

付款通过表单从多个隐藏字段传递到 WorldPay,包括:

<input type="hidden" name="amount" value="295.00" />

基本上,表单是通过 POST 提交给 WorldPay,用户按照多个步骤来处理他们的付款。完成后,用户将被重定向到指定的确认页面。

这似乎是 WorldPay 接受付款的典型方式。这里有一个明显的问题,隐藏字段的值很容易被任何具有 HTML 基础知识的人篡改。该表格直接发布到 WorldPay,因此我们没有 PostBack 来验证会员等级的金额。

我们可以选择在 WorldPay 向我们返回支付通知时验证支付金额,方法是在确认页面之前通过处理程序路由回调;但是,我想避免用户提交被篡改的表格,支付错​​误的金额并且没有获得会员资格,然后必须联系公司要求退还他们的钱的情况。

在处理付款之前,我们如何验证提交的金额是否正确?

更新

我想到我们还有一个问题,即使我们在服务器端验证表单发布,也无法阻止恶意用户将表单发布直接欺骗到 WorldPay。

【问题讨论】:

标签: c# asp.net validation worldpay


【解决方案1】:

这确实是一个漏洞,使用签名可以轻松解决。看看这个链接:

http://culttt.com/2012/07/25/integrating-worldpay-into-a-database-driven-website/

这个方法应该在帮助页面上更好的推广,太糟糕了。

【讨论】:

  • 谢谢尼克 - 很好的发现!这看起来正是我们所需要的。
【解决方案2】:

我能想到的一个解决方案是这样,捕获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;
}

【讨论】:

  • 我不确定这是否能解决我的问题 - 用户可以简单地关闭 Javascript,然后表单会立即发送到 WorldPay,它的系统不会更聪明。
猜你喜欢
  • 2012-09-17
  • 2013-02-11
  • 2015-10-11
  • 2017-07-28
  • 2017-10-03
  • 2020-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多