Solved

Complete javascript after call to PayPal

Posted on 2013-02-03
3
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

617 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