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 3b3262131..7e3476a12 100644
--- a/src/main/ui/static/templates/payment/v1/card_pay.js
+++ b/src/main/ui/static/templates/payment/v1/card_pay.js
@@ -4,7 +4,26 @@ $(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);
+ } else if (element.attachEvent) {
+ element.attachEvent('on' + eventName, eventHandler);
+ }
+ }
+ bindEvent(window,'message',function (evt){
+ let msg = JSON.parse(evt.data);
+ if (msg && msg.type=='3dsResult'){
+ evt.stopPropagation();
+ evt.stopImmediatePropagation();
+ $('.threeds-container').addClass('hide');
+ if (msg.success){
+ location.href = './result'
+ }else {
+ $errorMsgBox.text('[' + evt.errCode + ']' + evt.errMsg).show();
+ }
+ }
+ })
if (window.three_ds_params){
handleThreeDs(window.three_ds_params)
}
@@ -15,14 +34,6 @@ $(function () {
$('').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-container').addClass('hide');
- if (success) {
- location.href = './result'
- } else {
- $errorMsgBox.text('[' + errorCode + ']' + errorMsg).show();
- }
- }
form.submit();
$('.threeds-container').removeClass('hide')
}