2
votes

When connecting to PayPal I use a URL like this (I am using fake values here, but the structure is real):

https://www.paypal.com/cgi-bin/webscr?&business=ZDS346347&cmd=_xclick&amount=100&item_name=Test&no_note=1&no_shipping=1&rm=2&return=http://www.website.com/registration.php?paypal=1&classid=122&sessionid=264&studentid=2286

The problem is when I send this url, it truncates my return value query string from this:

paypal=1&classid=122&sessionid=264&studentid=2286

to this:

paypal=1

The ampersands in the return value are confusing it, but I need to use them so I can process those query string values on the return.

Is there someway, I can pass that whole return string to PayPal so it won't truncate after the first ampersand it hits.

Thanks,

Chris

1

1 Answers

0
votes

Wrap the passed URL with urlencode to turn the ampersands into PayPal-parsable characters, then when your URL gets called use urldecode to decode them.

This happens because PayPal's URL simply splits everything after the ? into chunks by the & symbol. It doesn't know when one is part of your website or not. So it's sending PayPal classid=122 as it's own key/value pair, not as a part of your URL. Encoding the URL this way should make it work correctly.

edit Referenced the wrong PHP functions. urlencode/decode are for GET parameter passing, htmlspecialchars is for storing HTML data