Validating payment amounts with WorldPay

Deadly 提交于 2019-12-04 14:46:30

It is a vulnerability indeed, it can be solved easily using a signature. Check out this link:

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

This method should be better promoted on the help page, too bad.

One solution I can think of is this, capture the form tag's submit:

<form id="myForm" onsubmit="return validatePayment();">

and then create that JavaScript file that looks like this:

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!