Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Thanked 0 Times in 0 Posts

    can a form have two actions?

    I have a form for submitting registration information, which displays a confirmation page with a PayPal button on it.

    Is it possible to skip the confirmation page and have a single button to run my processing script AND send PayPal's hidden inputs and run its script?

  2. #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 932 Times in 919 Posts
    You can do that by having your processing script send the information to Paypal.

    One action can do anything you want it to do so there is no provision made for more than one.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  3. #3
    New to the CF scene
    Join Date
    Jun 2013
    Thanked 0 Times in 0 Posts
    Can you help with the code? PayPal provides this:

    <form target="paypal" 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="GHDB7HUPTKJBG">
    <input type="image" src="images/Purchase_btn.gif" border="0" name="submit" alt="">
    <img alt="" border="0" src="pixel.gif" width="1" height="1">

    I guess lines 4 and 5 aren't needed. How do I make the actual POST of the hidden inputs happen without a button?

  4. #4
    Supreme Master coder!
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,168 Times in 1,159 Posts
    I would say that you don't use buttons, use PayPal Express.

  5. #5
    Regular Coder
    Join Date
    Sep 2011
    Thanked 27 Times in 27 Posts
    This could be accomplished in many ways.

    You could send an Ajax request with JavaScript on submit and then have the data forward to PayPal (if your site is set up for Ajax calls)

    Send a redirect header after you're done doing whatever it is you need to do. PayPal will accept the posted data in the $_GET form as well as post, so taking the data, parsing it, and appending it the end of the url should work just fine.

    PHP Code:
    #Do stuff on your site here first

    $paypal_url ''//The location the data must be sent to
    $paypal_data = array(); //The array of information to be sent
    header('location:' $paypal_url '?' http_build_query($paypal_data));
    Keep in mind that you can't guarantee a payment has made just because the user was forwarded to PayPal's website. They can easily close the tab or hit the back button and never pay, so don't mark them down as paid this way. Instead, consider the following:

    PayPal supports callback URL's so if someone sends a payment through the form, PayPal will send a "ping" (or notification) about it with the data for it back to your server. To avoid someone simulating the ping and getting something without really paying for it, you can then ping PayPal back confirming the data.

    It goes something like this:
    User makes a payment through PayPal
    PayPal sends data about the payment to your callback URL
    Your page pings the same data back to PayPal to confirm it's correct
    PayPal responds with whether the data is valid or not
    You can take actions with the data based on the response

    It's very handy, however if you plan on doing this without an upgraded account, I don't believe you can use the sandbox (I could be wrong) so you may pay a fee for testing (you'd be better off getting some money in your PayPal so it won't fee you).

    Helpful information on it:
    PDN - How To Article - Adding PayPal Checkout to Your 3rd-party Shopping Cart - PayPal
    IPN and PDT Variables - PayPal Developer

    You can find more by Googling around. Hope this helps!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts