Home > Archive > PHP Language > June 2005 > POSTing to another site on redirect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
POSTing to another site on redirect
|
|
| Jim Evans 2005-06-07, 3:59 pm |
| 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="formname.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
| |
|
| "Jim Evans" <longhairedjim@ntlworld.com> wrote in message
news:66ipe.3373$1O3.1378@newsfe5-win.ntli.net...
> 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.
PayPal allows for two hidden variables - are you using them all for options?
As an alternative, would it be possible to include the required data along
with the customer ID info? I'm guessing that this is info that is passed
back to you after processing, right? So, let's say it was a hidden field -
you could do something like: (I'm fudging the form name, since I don't
remember the PayPal names offhand)
print "<input type='hidden' name='paypaloption1'
value='$customerID/subscribe-$subscribe'>\n";
Of course, you would have to get the $customerID and $subscribe info in a
previous field to do this.
> 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?
I don't think you can add POST data, but you can certainly add GET data.
Have you tried PayPal with GET? I am under the impression that should work,
from what I've done with PayPal before.
Since this is PayPal specific, have you asked on the PayPal Developers
Forum?
> 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="formname.submit();"> ) I'm trying to
> keep it javascript free, so it'll be 100% accessible.
Alternately, you could add a "continue" button with all the data in hidden
fields, for those who don't have JavaScript enabled.
Just some thoughts - maybe they'll give you an idea.
| |
| Kimmo Laine 2005-06-07, 3:59 pm |
| "Jim Evans" <longhairedjim@ntlworld.com> kirjoitti
viestissä:66ipe.3373$1O3.1378@newsfe5-win.ntli.net...
> 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="formname.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)?
>
Have you tried posting a serialized array? You could put so XXXXing much
data to one serialized array and then unserialize it as it comes back...
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears
eternal.erectionN0@5P4Mgmail.com
| |
| Jim Evans 2005-06-07, 8:55 pm |
| Thanks Tony and Kimmo
I'm being awkward and trying to avoid having to ask the visitor about
the newsletter until after they've done the postage. I only want them to
click once, and be taken straight to Paypal. That means I wouldn't be
able to do any processing on it, such as concatenating or putting it
into an array.
I don't want the customer to see anything confusing - they'll be getting
a breakdown of the cart contents in their paypal account so I can only
use the paypal "custom" value, (which is never shown to the customer) to
identify them in the IPN.
Paypal works with GET, but if I pass more than a couple of cart items,
plus the customer details, I'll run out of characters in the GET string.
I hadn't really thought about asking on the paypal forums, as I was just
looking at the PHP prblem of passing the POST stuff - but I guess that's
going to have to be my next step.
Thanks guys.
Tony wrote:
> "Jim Evans" <longhairedjim@ntlworld.com> wrote in message
> news:66ipe.3373$1O3.1378@newsfe5-win.ntli.net...
>
>
>
> PayPal allows for two hidden variables - are you using them all for options?
>
> As an alternative, would it be possible to include the required data along
> with the customer ID info? I'm guessing that this is info that is passed
> back to you after processing, right? So, let's say it was a hidden field -
> you could do something like: (I'm fudging the form name, since I don't
> remember the PayPal names offhand)
>
> print "<input type='hidden' name='paypaloption1'
> value='$customerID/subscribe-$subscribe'>\n";
>
> Of course, you would have to get the $customerID and $subscribe info in a
> previous field to do this.
>
>
>
>
> I don't think you can add POST data, but you can certainly add GET data.
> Have you tried PayPal with GET? I am under the impression that should work,
> from what I've done with PayPal before.
>
> Since this is PayPal specific, have you asked on the PayPal Developers
> Forum?
>
>
>
>
> Alternately, you could add a "continue" button with all the data in hidden
> fields, for those who don't have JavaScript enabled.
>
> Just some thoughts - maybe they'll give you an idea.
>
>
| |
| Kimmo Laine 2005-06-08, 3:57 am |
| "Jim Evans" <longhairedjim@ntlworld.com> kirjoitti
viestissä:Clppe.3744$1O3.3417@newsfe5-win.ntli.net...
> Thanks Tony and Kimmo
>
> I'm being awkward and trying to avoid having to ask the visitor about the
> newsletter until after they've done the postage. I only want them to click
> once, and be taken straight to Paypal. That means I wouldn't be able to do
> any processing on it, such as concatenating or putting it into an array.
So what's wrong with processing the form once user _has_ decided about the
newsletter, end then redirecting the user to paypal with
header("Location: http://www.paypal.com?Put_your=get_methods_here");
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears
eternal.erectionN0@5P4Mgmail.com
| |
| Jim Evans 2005-06-08, 3:56 pm |
| Hi Kimmo
There's a limit on how many characters you can put in a GET request -
and with a reasonably full cart, along with all the customer's details I
can easily go over that. That's why it needs to be done by POST.
Looks like I'm going to have to put the javascript onload thing into
practice, with a "If this doesn't redirect you, click here" button to
submit the form for non-javascript clients.
Thanks anyway.
Kimmo Laine wrote:
> "Jim Evans" <longhairedjim@ntlworld.com> kirjoitti
> viestissä:Clppe.3744$1O3.3417@newsfe5-win.ntli.net...
>
>
>
>
> So what's wrong with processing the form once user _has_ decided about the
> newsletter, end then redirecting the user to paypal with
> header("Location: http://www.paypal.com?Put_your=get_methods_here");
>
|
|
|
|
|