6

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>
Vignesh Vino
  • 1,242
  • 4
  • 25
  • 50

1 Answers1

0

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>
pp_pduan
  • 3,392
  • 1
  • 9
  • 15
  • Thank you for your reply. According to the docs apdg.js is for mini browser mode not embeddedFlow – jtello Feb 24 '16 at 19:43
  • by the way I am getting this inside the popup (I get the same using dg.js inside de iframe so difference really) https://www.dropbox.com/s/oq4tbpyboq0oupc/Screen%20Shot%202016-02-24%20at%2012.21.38%20PM.png?dl=0 – jtello Feb 24 '16 at 20:21
  • Did you ever get this working? Is it possible that the embedded flow is only for payments and not for preapproval? Because they say that the embedded flow works on payments, I coulnd't find any mention of it working for preapproval. – theyuv Apr 27 '16 at 06:28