From 2f177be4a791c62eef184f8803f85efaff33a1c8 Mon Sep 17 00:00:00 2001 From: yixian Date: Fri, 14 May 2021 09:50:31 +0800 Subject: [PATCH] =?UTF-8?q?3ds=20=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 +-- src/main/ui/static/css/cardpay.css | 34 ++++++++++++++++++- .../static/templates/payment/v1/card_pay.js | 29 +++++++++++++--- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 11f20dfd3..bc28e6d54 100644 --- a/pom.xml +++ b/pom.xml @@ -5,11 +5,11 @@ au.com.royalpay.payment payment-parent - 2.2.29 + 2.2.30 4.0.0 manage - 2.3.86 + 2.3.87-SNAPSHOT UTF-8 2.4.0 diff --git a/src/main/ui/static/css/cardpay.css b/src/main/ui/static/css/cardpay.css index 2f0755782..30a402cbc 100644 --- a/src/main/ui/static/css/cardpay.css +++ b/src/main/ui/static/css/cardpay.css @@ -105,6 +105,9 @@ border-radius: 4px; height: 50px; } + .threeds-container .dialog{ + width:100%; + } } .btn-warning { @@ -184,4 +187,33 @@ 60% { opacity: 1; } -} \ No newline at end of file +} + +.threeds-container { + position: fixed; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(0, 0, 0, .4); + display: block; +} +.threeds-container.hide{ + display: none; +} + +.threeds-container .dialog{ + display: block; + width: 768px; + position: relative; + margin: 40px auto; + background: #fff; + max-height: 80%; + overflow: auto; +} + +.threeds-container .dialog>iframe{ + border: none; + width: 100%; +} + diff --git a/src/main/ui/static/templates/payment/v1/card_pay.js b/src/main/ui/static/templates/payment/v1/card_pay.js index 837ad66ac..e6507d7e3 100644 --- a/src/main/ui/static/templates/payment/v1/card_pay.js +++ b/src/main/ui/static/templates/payment/v1/card_pay.js @@ -4,6 +4,29 @@ $(function () { let cardFrame = new CardInputFrame($container, window.card_input_appid, window.card_input_token); let $errorMsgBox = $('#errorMsgBox'); let loading = $('.loading-container'); + + if (window.three_ds_params){ + handleThreeDs(window.three_ds_params) + } + + function handleThreeDs(threeDsParams) { + let form = $('
').attr('action', threeDsParams.acs_url).attr('method', 'post').css('display', 'none') + .attr('target', 'threeds-frame'); + $('').attr('name', 'PaReq').val(threeDsParams.pa_req).attr('type', 'hidden').appendTo(form); + $('').attr('name', 'TermUrl').val(threeDsParams.term_url).attr('type', 'hidden').appendTo(form); + $('body').append(form); + window.threeds_success = function (success, errorCode, errorMsg) { + $('#threeds-frame').addClass('hide'); + if (success) { + location.href = './result' + } else { + $errorMsgBox.text('[' + errorCode + ']' + errorMsg).show(); + } + } + form.submit(); + $('#threeds-frame').removeClass('hide') + } + cardFrame.onSuccess = function (secretData) { $.ajax({ url: 'commit', @@ -13,11 +36,7 @@ $(function () { success: function (res) { if (res.sdk_params) { let threeDsParams = JSON.parse(res.sdk_params); - let form = $('
').attr('action', threeDsParams.acs_url).attr('method', 'post').css('display', 'none'); - $('').attr('name', 'PaReq').val(threeDsParams.pa_req).attr('type', 'hidden').appendTo(form); - $('').attr('name', 'TermUrl').val(threeDsParams.term_url).attr('type', 'hidden').appendTo(form); - $('body').append(form); - form.submit(); + handleThreeDs(threeDsParams); return; } startCheckOrder(window.client_moniker, window.partner_order_id);