Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    8
    Thanks
    0
    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
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 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.
    Stephen
    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
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    0
    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">
    </form>

    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
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I would say that you don't use buttons, use PayPal Express.
    https://developer.paypal.com/docs/cl...t/overview-ec/

  • #5
    Regular Coder
    Join Date
    Sep 2011
    Posts
    419
    Thanks
    18
    Thanked 26 Times in 26 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.

    Example:
    PHP Code:
    <?php
    #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
    •