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 cd161aabf..83c405f7b 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,7 @@ $(function () { let cardFrame = new CardInputFrame($container, window.card_input_appid, window.card_input_token); let $errorMsgBox = $('#errorMsgBox'); let loading = $('.loading-container'); + function bindEvent(element, eventName, eventHandler) { if (element.addEventListener) { element.addEventListener(eventName, eventHandler, true); @@ -11,23 +12,24 @@ $(function () { element.attachEvent('on' + eventName, eventHandler); } } - bindEvent(window,'message',function (evt){ - if (!evt.data){ + + bindEvent(window, 'message', function (evt) { + if (!evt.data) { return } - let msg = JSON.parse(evt.data); - if (msg && msg.type=='3dsResult'){ + let msg = typeof evt.data == 'string' ? JSON.parse(evt.data) : evt.data; + if (msg && msg.type == '3dsResult') { evt.stopPropagation(); evt.stopImmediatePropagation(); $('.threeds-container').addClass('hide'); - if (msg.success){ + if (msg.success) { location.href = './result' - }else { + } else { $errorMsgBox.text('[' + evt.errCode + ']' + evt.errMsg).show(); } } }) - if (window.three_ds_params){ + if (window.three_ds_params) { handleThreeDs(window.three_ds_params) }