Closed rmuktader closed 11 years ago
I do exactly that with this snipped:
var dg = new PAYPAL.apps.DGFlow({trigger:'place_order'});
dg.startFlow(result.redirect);
Where result.redirect
is https://www.sandbox.paypal.com/incontext?token=EC-5B05061913748630E
. So not sure why your code isn't work, but perhaps you need to combine the two (set a tigger on PAYPAL.apps.DGFlow
construction and still call dg.startFlow
).
Brent, Thank you for your prompt reply. It made me realize that there IS a solution and I'll find it if I keep chipping away at the problem.
As it turns out var dg = new PAYPAL.apps.DGFlow({trigger:'paypal-submit'});
was executing before the button finished loading. So I placed it in the load's call back function.
For others who are reading this: the print-button.php uses echo $purchase->get_buy_button();
to print the button.
$(document).ready(function(){
// load paypal button
$('#paypal-container').load('print-button.php', function(){
var dg = new PAYPAL.apps.DGFlow({trigger:'paypal-submit'});
});
// on click
$('#paypal-submit').on('click', function(){
dg.startFlow($(this).attr('href'));
});
});
As it turns out
Thanks for sharing the solution @rmuktader
I have a question. But I did not know how to discuss it without posting it as an "issue".
I am loading the "Pay With PayPal" through AJAX because the when the user enters a coupon code I have to reload the button with the new price.
Unfortunately, the PayPal window does not open in a light-box after doing this.
I have tried
And :
Is there a solution this problem?