0

我正在尝试按照此处的说明进行 Worldpay 灯箱集成

<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>   

通过使用此脚本,网址显示 404 错误。任何帮助将不胜感激。

4

1 回答 1

0

根据 Worldpay 提供的相同代码,我刚刚遇到了这个问题。问题的原因仅仅是因为 libraryObject 在加载 DOM 之前被实例化 - Worldpay JavaScript 尝试将其 iFrame 注入到不存在的目标“custom-html”中。您需要做的就是在准备好的函数中移动对象实例化,以确保在您尝试访问之前已加载 DOM,例如

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

如果将调试设置更改为 true 可能会有所帮助 - 请注意,调试将写入浏览器控制台输出,而不是 Visual Studio 的!

于 2016-10-21T14:31:05.347 回答