Worldpay lightbox Integration

こ雲淡風輕ζ 提交于 2019-12-12 01:22:23

问题


I am trying to do the Worldpay lightbox integration as explained here

<script type="text/javascript">
    var customOptions = {
        iframeIntegrationId: 'libraryObject',
        iframeHelperURL: 'https://example.com/helper.html',
        iframeBaseURL: 'https://example.com',
        url: 'https://payments.worldpay.com/ngpp/integration/wpg/corporate?OrderKey=YOUR_ORDER_KEY&Ticket=YOUR_TICKET_ID',
        type: 'iframe',
        target: 'custom-html',
        accessibility: true,
        debug: false,
        language: 'en',
        country: 'gb',
        preferredPaymentMethod: 'VISA-SSL',
        successURL: 'https://example.com/success',
        cancelURL: 'https://example.com/cancel',
        failureURL: 'https://example.com/failure',
        pendingURL: 'https://example.com/pending',
        errorURL: 'https://example.com/error'
    };
    //initialise the library and pass options
    var libraryObject = new WPCL.Library();
    libraryObject.setup(customOptions);
</script>   

By using this script the url shows 404 error.Any help would really appreciated.


回答1:


I've just hit this problem, based upon the same code provided by Worldpay. The issue is caused simply because the libraryObject is being instantiated before the DOM is loaded - the Worldpay JavaScript attempts to inject its iFrame into the target 'custom-html' which doesn't exist. All you need to do is move the object instantiation within a ready function to ensure the DOM has loaded before you try to access it, e.g.

    $(document).ready(function () {
        // initialise the library and pass options
        var libraryObject = new WPCL.Library();
        libraryObject.setup(customOptions);
    });

It might help if you change the debug setting to true - note that the debug is written to the browser console output rather than Visual Studio's!



来源:https://stackoverflow.com/questions/36265264/worldpay-lightbox-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!