Paypal preapproval payment using embeded Light box

2020-07-11 04:44发布

问题:

I am working in embedded adaptive preapproval payment now the issue I am facing is how to implement preapproval payment using light box.

I have implemented pay action by setting paykey using light box its working good, but same the thing I have followed with little modification in code for preapproval request was not working light box get hangs up. kindly let me know what I am missing here.

HTML code:

<html>
<head>
    <script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>
</head>

<body>
    <form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapprovalkey" target="PPDGFrame" class="standard">
        <label for="buy">Buy Now:</label>
        <input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
        <input id="type" type="hidden" name="expType" value="light">
        <input id="preapprovalkey" type="hidden" name="preapprovalkey" value="{{preapprovalkey}}">
    </form>
    <script type="text/javascript" charset="utf-8">
        var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });
    </script>
</body>
</html>

回答1:

The dg.js is outdated as PayPal is sunsetting the DG product, you would include the 'apdg.js' instead, and change the action URL from pay to preapproval

<html>

<head>
  <title>AP Redirection Demo</title>
  <script src="https://www.paypalobjects.com/js/external/apdg.js" type="text/javascript"></script>
</head>

<body>
  <form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapproval" target="PPDGFrame" class="standard">
    <label for="buy">Pay Now:</label>
    <input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
    <input id="type" type="hidden" name="expType" value="light">
    <input id="preapprovalkey" type="input" name="preapprovalkey" value="insert_preapproval_key">
  </form>
  <script type="text/javascript" charset="utf-8">
    var dgFlowMini = new PAYPAL.apps.DGFlowMini({
      trigger: 'submitBtn'
    });
  </script>

</body>

</html>