在InAppBrowser中实现3DSecure

时间:2014-09-19 12:16:09

标签: javascript angularjs cordova ionic-framework

我目前正在编写一款使用3DS(3DSecure)的应用,但我无法在我的移动设备上运行(目前正在Android上测试)。

当我获得银行URL时,我会打开窗口。打开它,它会重定向到3DSecured网页,我可以进行身份​​验证,但我不能在流程结束时关闭inAppBrowser。

以下是用户点击的弹出窗口:

function showPopup3ds($ionicPopup, $scope, $window) {
    var myPopup = $ionicPopup.show({
        title: 'Paiement sécurisé',
        subTitle: 'Confirmez votre transaction grâce au 3D Secure fourni par votre établissement bancaire.',
        scope: $scope,
        buttons: [{
            text: '<b>Continuer</b>',
            type: 'button-positive',
            onTap: function(e) {
                // creating the 'formresult' window with custom features prior to submitting the form
                ref = $window.open($scope.p3ds.threeDSEncodedPareq, 'formresult', 'toolbar=0,scrollbars=0');

                // <form id="redirectForm" name="redirectForm" target="formresult" action="{{p3ds.threeDSAcsUrl | trusted }}" method="POST" class="hide"> 
                document.forms['redirectForm'].submit();
                e.preventDefault();
            }
        }]
    });
}

然后,juste:

showPopup3ds($ionicPopup, $scope, $window);
socket.on(result.veResPAReqInfo.threeDSRequestId, function(data) {
    console.log(ref);
    ref.close();
    showPopupResult($ionicPopup, $scope, data.success);
})

但我无法关闭它,或者听取任何事件,因为de page被重定向。它不像新标签或新窗口,而是重定向。

我觉得有点绝望,我希望我可以打开镀铬标签或任何其他。

希望你能帮助我。

Kai23

编辑:我就是这样做的:

在我看来(payment_details.html),我有当前的表格:

<form id="redirectForm" name="redirectForm" target="hidden_iframe" action="{{p3ds.threeDSAcsUrl | trusted }}" method="POST" class="hide"> 
    <input type="hidden" id="PaReq" name="PaReq" value="{{p3ds.threeDSEncodedPareq}}"> 
    <input type="hidden" id="TermUrl" name="TermUrl" value="{{p3ds.TermUrl}}"> 
    <input type="hidden" id="MD" name="MD" value="{{p3ds.MD}}"> 
</form>

我有一个像这样的离子模态视图:

<ion-modal-view>
    <ion-header-bar>
        <h1 class="title">Paiement sécurisé 3-D Secure</h1>
        <button class="button button-dark" ng-click="hide_modal(modal)">Fermer</button>
    </ion-header-bar>
    <ion-content  scroll="true" overflow-scroll="true" class="has-header padding">
        <iframe name="hidden_iframe" style="width:100%;height:100%"></iframe>
    </ion-content>
</ion-modal-view>

最后,在我的PaymentController中,我做了类似的事情:

$scope.p3ds.threeDSAcsUrl = result.
$scope.p3ds.threeDSEncodedPareq = result.
$scope.p3ds.TermUrl = api_url + '/retour-banque?token=' + $window.sessionStorage['
$scope.p3ds.MD = result.id;

var myPopup = $ionicPopup.show({
    title: 'Paiement sécurisé',
    subTitle: 'Confirmez votre transaction grâce au 3D Secure fourni par votre établissement bancaire.',
    scope: $scope,
    buttons: [{
        text: '<b>Continuer</b>',
        type: 'button-positive',
        onTap: function(e) {
            $ionicModal.fromTemplateUrl('templates/payment/popup/modal_3DS.html', {
                scope: $scope,
                animation: 'slide-in-up'
            }).then(function(modal) {
                $scope.modal = modal;
                $scope.modal.show();
                document.forms['redirectForm'].submit();
            });
        }
    }]
});

服务器端,这是它的样子(我使用nodejs,并且欺骗了很多)

// Once the transaction is complete
res.ok("<p>Votre transaction a bien été enregistrée ! Revenez sur votre compte Payname en cliquant sur « fermer »");

// English : res.ok("<p>Transaction succeeded. Come back to your Payname account using the close button");

这将是PHP中的

die("...")

希望它有所帮助,

0 个答案:

没有答案