POSTing to another site on redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Evans

    #1

    POSTing to another site on redirect

    Hi All

    I'm building a shopping cart that ties in with PayPal for payments.
    After working out the postage charge, I want the user to be able to
    confirm if they'll sign up to a newsletter or not, and then to be taken
    to Paypal. I'd like to do all that with just one click.

    Paypal only lets you pass one hidden variable, and I need that to
    identify the customer in the back end stuff, so I can't check on the
    newsletter thing after payment.

    I'm looking for a way to process the form input myself, before sending
    the user to PayPal. How can I add POST data to a "Location" header?

    Although I could do it by sending them to a script that does the
    processing for the newsletter, and then uses javascript to submit the
    form values using post (e.g. <body onload="formnam e.submit();">) I'm
    trying to keep it javascript free, so it'll be 100% accessible.

    Anyone know how to add the headers (or have a suggestion how else I can
    do this)?

    Thanks

    Jim
  • mattvenables

    #2
    Re: POSTing to another site on redirect

    why not concat some sort of delimiter and the newsletter value to the
    customer identity variable you're passing to paypal. for example, if
    youre passing "12345" to paypal, why not send "12345.y" if they want
    the newsletter and just explode the string at the "." when you get it
    back?

    Comment

    • Ken Robinson

      #3
      Re: POSTing to another site on redirect

      Jim Evans wrote:
      [color=blue]
      > Paypal only lets you pass one hidden variable, and I need that to
      > identify the customer in the back end stuff, so I can't check on the
      > newsletter thing after payment.[/color]

      What do you mean by "Paypal only lets you pass one hidden variable"?

      Paypal has no idea how you pass the variables in your form as long as
      it uses the POST methon
      [color=blue]
      >
      > I'm looking for a way to process the form input myself, before sending
      > the user to PayPal. How can I add POST data to a "Location" header?
      >
      > Although I could do it by sending them to a script that does the
      > processing for the newsletter, and then uses javascript to submit the
      > form values using post (e.g. <body onload="formnam e.submit();">) I'm
      > trying to keep it javascript free, so it'll be 100% accessible.[/color]

      That's the easiest way to do it. If you want to make sure it works when
      Javascript is disabled, put in some code that basically says "Oops ...
      submit to Paypal didn't work, please press 'Here' to try again". The
      'Here' would be a button that would send the hidden form values to
      Paypal.

      Ken

      Comment

      • Tony

        #4
        Re: POSTing to another site on redirect

        "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
        news:1118164044 .855130.116270@ g43g2000cwa.goo glegroups.com.. .[color=blue]
        > Jim Evans wrote:
        >[color=green]
        >> Paypal only lets you pass one hidden variable, and I need that to
        >> identify the customer in the back end stuff, so I can't check on the
        >> newsletter thing after payment.[/color]
        >
        > What do you mean by "Paypal only lets you pass one hidden variable"?
        >
        > Paypal has no idea how you pass the variables in your form as long as
        > it uses the POST methon[/color]

        The way the PayPal processing works is that you send it the information,
        then it processes the payment and posts BACK to your site with a list of
        variables.

        The thing is, it only includes certain variables - so any data you want
        passed back to your site after the payment is processed must fit within the
        list of variables that are allowed. Otherwise, they're dropped.
        [color=blue][color=green]
        >>
        >> I'm looking for a way to process the form input myself, before sending
        >> the user to PayPal. How can I add POST data to a "Location" header?
        >>
        >> Although I could do it by sending them to a script that does the
        >> processing for the newsletter, and then uses javascript to submit the
        >> form values using post (e.g. <body onload="formnam e.submit();">) I'm
        >> trying to keep it javascript free, so it'll be 100% accessible.[/color][/color]

        Here's a thought: What about using a Session variable to set the value of
        "subscribe" before going to PayPal (you could do that in your automatically
        forwarding page without using JavaScript) and read that Session variable
        back when they return?
        [color=blue]
        >[/color]


        Comment

        • Jim Evans

          #5
          Re: POSTing to another site on redirect

          Hi Ken

          I'm using paypal as the checkout for my cart. That means I have to send
          all the cart contents alng with postage charges and any customer details
          I have as a POST (although I've just found out GET also works) to their
          script.

          I'm hoping to avoid the "oops" method, although it seems likely to be
          the one I take, if concatenating variables doesn't work. Thanks for the
          suggestion.

          Ken Robinson wrote:[color=blue]
          > Jim Evans wrote:
          >
          >[color=green]
          >>Paypal only lets you pass one hidden variable, and I need that to
          >>identify the customer in the back end stuff, so I can't check on the
          >>newsletter thing after payment.[/color]
          >
          >
          > What do you mean by "Paypal only lets you pass one hidden variable"?
          >
          > Paypal has no idea how you pass the variables in your form as long as
          > it uses the POST methon
          >
          >[color=green]
          >>I'm looking for a way to process the form input myself, before sending
          >>the user to PayPal. How can I add POST data to a "Location" header?
          >>
          >>Although I could do it by sending them to a script that does the
          >>processing for the newsletter, and then uses javascript to submit the
          >>form values using post (e.g. <body onload="formnam e.submit();">) I'm
          >>trying to keep it javascript free, so it'll be 100% accessible.[/color]
          >
          >
          > That's the easiest way to do it. If you want to make sure it works when
          > Javascript is disabled, put in some code that basically says "Oops ...
          > submit to Paypal didn't work, please press 'Here' to try again". The
          > 'Here' would be a button that would send the hidden form values to
          > Paypal.
          >
          > Ken
          >[/color]

          Comment

          • Jim Evans

            #6
            Re: POSTing to another site on redirect

            Hi Tony

            Session variables would be the obvious answer - I was trying to do most
            of the processing in the IPN script - which wouldn't be linked to the
            session.

            If I get the customer to confirm the newsletter subscription before the
            postage is calculated, I can drop it into a session variable, but I was
            hoping to make it a bit more logical and do it after that. To put that
            into a session variable then would sill involve doing something on my
            server, before directing the client over to paypal, complete with variables.

            Tony wrote:[color=blue]
            > "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
            > news:1118164044 .855130.116270@ g43g2000cwa.goo glegroups.com.. .
            >[color=green]
            >>Jim Evans wrote:
            >>
            >>[color=darkred]
            >>>Paypal only lets you pass one hidden variable, and I need that to
            >>>identify the customer in the back end stuff, so I can't check on the
            >>>newsletter thing after payment.[/color]
            >>
            >>What do you mean by "Paypal only lets you pass one hidden variable"?
            >>
            >>Paypal has no idea how you pass the variables in your form as long as
            >>it uses the POST methon[/color]
            >
            >
            > The way the PayPal processing works is that you send it the information,
            > then it processes the payment and posts BACK to your site with a list of
            > variables.
            >
            > The thing is, it only includes certain variables - so any data you want
            > passed back to your site after the payment is processed must fit within the
            > list of variables that are allowed. Otherwise, they're dropped.
            >
            >[color=green][color=darkred]
            >>>I'm looking for a way to process the form input myself, before sending
            >>>the user to PayPal. How can I add POST data to a "Location" header?
            >>>
            >>>Although I could do it by sending them to a script that does the
            >>>processing for the newsletter, and then uses javascript to submit the
            >>>form values using post (e.g. <body onload="formnam e.submit();">) I'm
            >>>trying to keep it javascript free, so it'll be 100% accessible.[/color][/color]
            >
            >
            > Here's a thought: What about using a Session variable to set the value of
            > "subscribe" before going to PayPal (you could do that in your automatically
            > forwarding page without using JavaScript) and read that Session variable
            > back when they return?
            >
            >
            >
            >[/color]

            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: POSTing to another site on redirect

              Jim Evans wrote:[color=blue]
              > I'm building a shopping cart that ties in with PayPal for payments.
              > After working out the postage charge, I want the user to be able to
              > confirm if they'll sign up to a newsletter or not, and then to be taken
              > to Paypal. I'd like to do all that with just one click.[/color]
              [color=blue]
              > Paypal only lets you pass one hidden variable, and I need that to
              > identify the customer in the back end stuff, so I can't check on the
              > newsletter thing after payment.[/color]
              <snip>

              I seriously doubt only one variable claim. Is it PayPal Single Item
              Purchase system?? Also, you can use http://www.php.net/serialize
              function to send serialized variables in single variable.

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

              Comment

              • Tony

                #8
                Re: POSTing to another site on redirect

                "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                news:1118246659 .112660.322330@ o13g2000cwo.goo glegroups.com.. .[color=blue]
                > Jim Evans wrote:[color=green]
                >> I'm building a shopping cart that ties in with PayPal for payments.
                >> After working out the postage charge, I want the user to be able to
                >> confirm if they'll sign up to a newsletter or not, and then to be taken
                >> to Paypal. I'd like to do all that with just one click.[/color]
                >[color=green]
                >> Paypal only lets you pass one hidden variable, and I need that to
                >> identify the customer in the back end stuff, so I can't check on the
                >> newsletter thing after payment.[/color]
                > <snip>
                >
                > I seriously doubt only one variable claim. Is it PayPal Single Item
                > Purchase system?? Also, you can use http://www.php.net/serialize
                > function to send serialized variables in single variable.[/color]

                PayPal limits the number of variables that get passed back to your IPN
                script. You can pass PayPal as many variables as you want, they won't come
                out the other end.

                Jim -

                I recall having a similar situation once, where I needed more information in
                the IPN script than was available to be passed through the PayPal processing
                system. What I did to solve this was I stored the ALL of the necessary data
                in a simple text file and passed the file name as the variable to PayPal.
                Then, the IPN script retrieved the data from the file, using the file name
                that PayPal passed back to it.

                That's the best I can offer - hope it helps!


                Comment

                • R. Rajesh Jeba Anbiah

                  #9
                  Re: POSTing to another site on redirect

                  Tony wrote:[color=blue]
                  > "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                  > news:1118246659 .112660.322330@ o13g2000cwo.goo glegroups.com.. .[/color]
                  <snip>[color=blue][color=green]
                  > > I seriously doubt only one variable claim. Is it PayPal Single Item
                  > > Purchase system?? Also, you can use http://www.php.net/serialize
                  > > function to send serialized variables in single variable.[/color]
                  >
                  > PayPal limits the number of variables that get passed back to your IPN
                  > script. You can pass PayPal as many variables as you want, they won't come
                  > out the other end.[/color]

                  The later is true. But, however you check the manual.

                  --
                  <?php echo 'Just another PHP saint'; ?>
                  Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

                  Comment

                  • Jim Evans

                    #10
                    Re: POSTing to another site on redirect

                    Thanks guys.

                    None of these will work, because my server won't know what option has
                    been selected on the form (and therefore won't be able to
                    process/serialise/store it), unless it's posted to the server, instead
                    of direct to PayPal. I guess I'm stuck with using a JavaScript to force
                    the form to post invisibly. I'll just drop in a "click here if you don't
                    get redirected" for non-javascript clients.

                    Thanks anyway everyone

                    R. Rajesh Jeba Anbiah wrote:[color=blue]
                    > Tony wrote:
                    >[color=green]
                    >>"R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                    >>news:11182466 59.112660.32233 0@o13g2000cwo.g ooglegroups.com ...[/color]
                    >
                    > <snip>
                    >[color=green][color=darkred]
                    >>> I seriously doubt only one variable claim. Is it PayPal Single Item
                    >>>Purchase system?? Also, you can use http://www.php.net/serialize
                    >>>function to send serialized variables in single variable.[/color]
                    >>
                    >>PayPal limits the number of variables that get passed back to your IPN
                    >>script. You can pass PayPal as many variables as you want, they won't come
                    >>out the other end.[/color]
                    >
                    >
                    > The later is true. But, however you check the manual.
                    >
                    > --
                    > <?php echo 'Just another PHP saint'; ?>
                    > Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com
                    >[/color]

                    Comment

                    • R. Rajesh Jeba Anbiah

                      #11
                      Re: POSTing to another site on redirect

                      Jim Evans wrote:[color=blue]
                      > Thanks guys.
                      >
                      > None of these will work, because my server won't know what option has
                      > been selected on the form (and therefore won't be able to
                      > process/serialise/store it), unless it's posted to the server, instead
                      > of direct to PayPal.[/color]
                      <snip>

                      IIRC, I did send n number of variables to PayPal. So, check the
                      manual. Even if it is supporting just one variable, it can easily be
                      solved by the design:

                      <?php
                      $user_id = 189;
                      ?>
                      Do you want to subscribe to Kalki? <br />
                      <input name="custom" type="radio" value="<?php echo
                      htmlspecialchar s(serialize(arr ay('user_id'=>$ user_id,
                      'subscribe'=>'1 ')));?>" checked="checke d" /> Yes <br />
                      <input name="custom" type="radio" value="<?php echo
                      htmlspecialchar s(serialize(arr ay('user_id'=>$ user_id,
                      'subscribe'=>'0 ')));?>" /> No <br />
                      <input name="submit" type="submit" value="Go and lose your money at
                      PayPal" />

                      --
                      <?php echo 'Just another PHP saint'; ?>
                      Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

                      Comment

                      Working...