Solved

Complete javascript after call to PayPal

Posted on 2013-02-03
3
342 Views
Last Modified: 2016-03-24
What is the best way to implement a call to PayPal so that after a customer completes the payment process, they are then directed back to the original site where the rest of the javascript can continue?

Perhaps I am not even thinking of this problem in the right terms  Basically I want some javascript code to run, but only after a successful PayPal payment has been completed.

Here is the code for the call to PayPal:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_s-xclick">
  <input type="hidden" name="hosted_button_id" value="123456789">
  <input type="image"
      src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif"
      border="0" name="submit"
      alt="PayPal - The safer, easier way to pay online!">
  <img alt="" border="0"
      src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1"
      height="1">
</form>

Open in new window


Any ideas or best practices for me to consider?  Thanks.
0
Comment
Question by:DanielAttard
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 38848823
when you create your form(button) with paypal, you have the possibility to set this URL in the step two.
You can use the same url/page and add a parameter in the url
or use a different page
0
 
LVL 11

Accepted Solution

by:
Andrew Angell earned 500 total points
ID: 38849006
When using a standard button like you are you just need to set the return URL during the button creation process.  This will be where the user is sent after successful payment.  

That said, there is no guarantee that the user will make it back to this page with Payments Standard.  Even if you have auto-return enabled in your PayPal account the buyer could simply close the browser prior to the return and the code you want to run would never run.

If you have code that you need to make sure runs every time, guaranteed, then you should use Instant Payment Notification (IPN) to handle that for you.  IPN will be triggered regardless of whether or not the user makes it back to your site.
0
 

Author Comment

by:DanielAttard
ID: 38849660
Great points angelleye.  I hadn't thought about the possibility of the user not making it to the return URL.  In my particular use-case, I absolutely need my javascript code to run at the moment the payment is processed on PayPal.  I will start reading-up on IPN.
Thanks.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now