Paymill:至少有一家银行的3D-Secure漏洞?

时间:2013-02-22 19:10:12

标签: 3d-secure paymill

我使用3D安全支付Paymill API付款:

paymill.createToken(params, paymillResponseHandler, tdsInit, tdsCleanup);

这部分来自文档,完全不起作用:

var tdsInit = function(iframeUrl, cancelFn) {
  var body   = document.body || document.getElementsByTagName('body')[0];
  var iframe = document.createElement('iframe');

  iframe.id               = 'tdsIframe';
  iframe.src              = iframeUrl;
  iframe.width            = 600;
  iframe.height           = 500;
  iframe.style.zIndex     = 0xffffffff;
  iframe.style.background = '#fff';
  iframe.style.position   = 'absolute';

  body.insertBefore(iframe, body.firstChild);
};

所以我这样做:

function tdsInit(iframeUrl, cancelFn) {
    var body   = document.body;
    var div3D  = document.createElement("div");
    div3D.id = "div3Dsecure";
    body.insertBefore(div3D, body.firstChild);
    var pareq = decodeURIComponent(iframeUrl.params.PaReq.replace(/\+/g,  " "));
    var termurl = decodeURIComponent(iframeUrl.params.TermUrl.replace(/\+/g,  " "));
    div3D.innerHTML='.$dot.'<form id="3Dsecureform" action="'.$dot.'+iframeUrl.url+'.$dot.'" method="POST"><textarea name="PaReq" style="display:none">'.$dot.'+pareq+'.$dot.'</textarea><input type="hidden" name="TermUrl" value='.$dot.'+termurl+'.$dot.'><input type="hidden" name="MD" value='.$dot.'+iframeUrl.params.MD+'.$dot.'></form>'.$dot.';
    var iframe = document.createElement("iframe");
    iframe.id               = "tdsIframe";
    iframe.src              = "";
    iframe.width            = 600;
    iframe.height           = 500;
    iframe.style.zIndex     = 0xffffffff;
    iframe.style.background = "#fff";
    iframe.style.position   = "absolute";
    iframe.scrolling        = "no";
    body.insertBefore(iframe, body.firstChild);
    document.forms[0].target = "tdsIframe";
    document.forms[0].submit();
};

付款还可以,但是当客户使用Sberbank的卡付款时,我们遇到了问题: iframe而不是显示来自ACS的3D安全页面只会做出有关成功验证此付款的回复。

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Return to Merchant's site</title>
<SCRIPT>
            function onLoadHandler() {
                document["PAResForm"].submit();
            }
        </SCRIPT>
</head>
<body onLoad="onLoadHandler();">
<BR>
<BR>Processing...
        <FORM NAME="PAResForm" METHOD="post" ACTION="https://ctpe.net/payment/threedsecure?ndcid=8BE948ADB647AF64A9C2640B81DC4B82.lon-vm-fe05&jsessionid=.lon-vm-ps02">
<INPUT NAME="PaRes" TYPE="hidden" VALUE="eJxVkLFuAjEMhl/Fyt7kOAnRwRcGKBtT6YyinI+LlMSVExCP30OEVpW82L/9/bZxe08RbiQlcB7USncKKHseQ74M6ut0eHtXW4unWYj2n+SvQhaPVIq7EIRxUPcprc+bc69XXdd3G2XxQ4TFYmPaBal7NK8U6SHveCS7RvOXPOuNbA8syVXgCTgTsEBiIaBIiXItEJbINxfDCM57lse2UBnqTFC+yYcpeFcXO90sXtyny56qC9EeSfzsctVXia2vKWjaEeZ30Px7wQ9uC2z4"><INPUT NAME="MD" TYPE="hidden" VALUE="8a8394823cd8c78d013cf365e77a3ac5">
</FORM>
</body>
</html>

首先我认为Sberbank存在一些错误,但是客户使用另一个PSP进行了另一次付款并且拥有Sberbank的3D安全窗口:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT LANGUAGE="JavaScript" SRC="/sberbank/common/global.js"></SCRIPT>
<LINK href="/sberbank/common/va_style.css" rel=STYLESHEET type="text/css">
<title>Verified by VISA - Пароль безопасности</title>
<SCRIPT type="text/javascript">
strBeforeUnload = "Ваша транзакция не завершена!\
Для продолжения, нажмите кнопку 'Отмена' и введите пароль на странице проверки безопасности.";
<!-- page for OTP_SMS -->
var PAMs = new Array();
PAMs[0] = new Array("0","None");

我无法理解我在哪里犯了错误。也许有人可以帮助我?

1 个答案:

答案 0 :(得分:5)

我很抱歉,但文档中似乎有一个过时的代码示例。请看一下tdsInit()回调的以下示例(这是Bridge.js默认实现的简化版本,以说明该过程):

var tdsInit = function tdsInit(redirect, cancelCallback) {
    var url = redirect.url, params = redirect.params;
    var body = document.body || document.getElementsByTagName('body')[0];

    var iframe = document.createElement('iframe');
    body.insertBefore(iframe, body.firstChild);

    var iframeDoc = iframe.contentWindow || iframe.contentDocument;
    if (iframeDoc.document) iframeDoc = iframeDoc.document;

    var form = iframeDoc.createElement('form');
    form.method = 'post';
    form.action = url;

    for (var k in params) {
        var input = iframeDoc.createElement('input');
        input.type = 'hidden';
        input.name = k;
        input.value = decodeURIComponent(params[k]);
        form.appendChild(input);
    }

    if (iframeDoc.body) iframeDoc.body.appendChild(form);
    else iframeDoc.appendChild(form);

    form.submit();
};

但请注意,tdsInit和tdsEnd都是可选参数。如果您想自定义iframe的外观和感觉,则只需要这些。