views:

94

answers:

1

I have an IPN script for PayPal, and as I can only rely on a log file to debug it and it's hard to maintain a testing server (and to test even for I am a one-man team), I am considering using cURL to run other scripts which would handle sending of emails, logging into database and updating of logs.

This way, if I have to send a new email (for some reason, clients never made up their mind), I don't have to tangle with the IPN script. Not just that, if for some reasons those new additions cause a FATAL error, the original IPN still runs. Is this a good idea?

A: 

Why chew up valuable apache processes (assuming apache/mod_php)?

If you want to do things asynchronously, cURL won't help, since it doesn't operate like that. You might look at kicking off some external scripts via the command line, if you want to do some things in a fire-and-forget sort of way.

Otherwise, what's wrong with just abstracting this peripheral (to IPN handling) activity like you would any other abstraction? Wrapping it in a function being the most obvious thing.

Then if you need to add some new feature (sending a new kind of email, for example), you just write a function that sends that email, test it until it works, then add a single line to your IPN-handling script.

Maybe I'm missing something?

Responding to your edit: Obviously, you should avoid fatal errors at all costs. But you should be able to avoid them without resorting to these kinds of heroics. For example, if you need to send an email, then write a function to send it based on some parameters. Ensure that function won't create fatal errors by writing enough test coverage.

timdev
Yes, it's true. However, because PayPal executes IPN and there is no way to see the output, and live/test conditions are different are times. So I am just exploring a way to add 'plugins' to the IPN script which can fail graciously.
Extrakun
I was just dealing with the pain that is IPN integration yesterday, so I feel your pain! My best advice is just to structure things nicely so it's easy to individually test processes, and easy to turn stuff off in case you need to debug some IPN-specific issue.
timdev