April 18, 2005

189 words 1 min read

Perl Snips

I’ve been working on a PayPal IPN Script. The key to PayPal IPN is that they post the data to your server, you have to post it back to them with one extra query attached. Most scripts I’ve seen read STDIN directly to get the post and then break out the rest of the data from there, but I dont want to do that. I like my mod_CGI. The only problem is that when using this module, you can no longer directly read the POST data. I’ve found a work around

@names = $q->param;foreach $key (@names){$z .= $key . "=" . param($key) . "\&";}

This snip of code will rebuild the POST in the order it was recived into the variable $z. Its not a “preety” solution, but it does work (It also adds an additional & at the end, but thats ok with my needs since I have to attach another query to the end for paypal).

Otherwise I have to say working with the PayPal IPN system is very intresting, and once you hack through all the crap thats thrown at you — its really very simple.