How to execute Javascript from within a PL/SQL Page Process?
Russ CMar 4 2013 — edited Mar 5 2013Hello All,
I'm developing a page that calls PayPal's Adaptive Payments API and I've had success in POSTing to PayPal and getting a response with a valid "Paykey" using a PL/SQL page process. I heavily relied on "Integrating Application Express with PayPal Payments Pro" found at http://www.oracle.com/technetwork/developer-tools/apex/integrating-application-express-wit-129259.pdf
Now I need to call PayPal again(from within the same Page Process) in order for my user to approve the payment I just setup.
PayPal's API doc says to execute the following Javascript, but I can't figure out how to call it from within a PL/SQL Page Process...:
function javascriptLaunch()
{
flow_Javascript = new PAYPAL.apps.DGFlow({ expType: "light" });
flow_Javascript.startFlow("https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=<paykey returned earlier>");
}
javascriptLaunch(); -- To auto-execute the function
Note: The "src" in the header is:
<head>
<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>
</head>
So if I take the URL in the startFlow (and provide a valid paykey) and put it in my browser URL I get an approval page as expected, but I need to have the approval "pop up" in a lightbox from within a PL/SQL Page Process.
I figure it is something simple, but I need your help.
Thanks,
Russ
Below I have included the entire contents of a local file I created to prove the javascriptLaunch works and is not the problem (of course PayPal give an error in the lightbox since it can't find a paykey of "junk"):
<html>
<head>
<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function javascriptLaunch()
{
flow_Javascript = new PAYPAL.apps.DGFlow({ expType: "light" });
flow_Javascript.startFlow("https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=junk");
}
javascriptLaunch();
</script>
</html>