X-Frame-Options forbidding redirect to PayPal

后端 未结 6 546
旧时难觅i
旧时难觅i 2021-01-02 23:09

I\'ve got a payment system that won\'t redirect to paypal because of the error: \"Refused to display document because display forbidden by X-Frame-Options.\" The form is po

6条回答
  •  梦谈多话
    2021-01-02 23:59

    I'm currently working with paypal. You could, at first, think "Hey! tons of doc!! yay!", but it actually SUCKS. Tons of doc that assume you already know what you're looking for. Try the following JS code (you should have already invoked setExpressCheckout method and have a token):

    $(document).ready(function() {
        //asynchronously fetch paypal's javascript
        jQuery.getScript('https://www.paypalobjects.com/js/external/dg.js', function(){console.debug("javascript loaded");});
    });
    
    //the handler that opens the iframe should be the following. This code assumes token variable has already been initalized
    var dg = new PAYPAL.apps.DGFlow({trigger:null, expType:"light"});
    dg.startFlow('https://www.sandbox.paypal.com/incontext?token=' +token);
    

    The only thing I needed here whas the F***NG correct URL to use for testing (sandbox environment).

    By the way, make sure you are logged in into your sandbox account before testing ;)

提交回复
热议问题