Solved

Complete javascript after call to PayPal

Posted on 2013-02-03
3
348 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON help 8 48
XJS:  how to throw error if no match found 8 59
Making an unordered list with background-image responsive 8 24
Add Promise to Existing Code 6 32
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 …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

751 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