PHP Tutorial: PayPal Instant Payment Notification (IPN)

Got a letterIn a previous post I tried to give an introduction on how to get started with PayPal Payment Data Transfers (PDT). PDT is very handy in several cases, but you can’t always rely on it since it requires the user to return to your page after doing the payment. That will often happen, but it’s not guaranteed to happen. If you for example want to mark an order in your system as paid or something like that, you most likely want to use PayPal Instant Payment Notifications (IPN) in addition to PDT.

Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use it to automate back-office and administrative functions, such as fulfilling orders, tracking customers, and providing status and other information related to a transaction. — PayPal

Once again the documentation, tutorials and code samples I found on this was a bit all over the place. Sort of messy and outdated. So, once again I decided to do my own thing and just follow the steps required and implement them myself. And since the tutorial on PDT turned out to be a bit of a success, I decided to share this too. Hopefully it can make the lives of fellow developers easier :)

Continue reading

PHP: Tail tackling large files

Needed a function that could get me the last N lines of a log file. Wanted it to be efficient and not dependent on anything other than my code.

Found some versions, but they were either a bit messy or depended on unstable arithmetic (where filesize is greater than PHP_INT_MAX). So, I decided to take on the challenge and try to write one myself. Nice little exercise :)

Continue reading

Skype crash on Windows with offset 006eb5e2

Probably an obscure issue I’ll never experience again, but in case it does, I found a solution that worked in a thread on Yahoo Answers.

Run one of the commands below in a Command Prompt or just stick it into the Run dialog (win + r). Then restart Skype *sigh*… :roll:

Windows XP

> del "%userprofile%\Application Data\Skype\shared.xml"

Windows 7 (and Vista?)

> del "%appdata%\Skype\shared.xml"
Note: You may of course also find and delete the file by using Windows Explorer. I just prefer a quick one-off command :)

/a

Java: How to deal with the BOM in a Unicode InputStream

Ok, so I was happily reading CSV files from an SFTP server. The file content is returned as an InputStream and I I used a BufferedReader to read it line by line. Each line contained either a header or an order. The header lines started with the string “HDR”.

However, I suddenly discovered that my code was consistently skipping the first header (and as a result the orders belonging to it). The reason, I found, was simple. The first header, on the first line, didn’t start with “HDR”, it started with “□HDR”! And that undisplayable square turned out to be a Unicode Byte Order Mark (BOM).

Continue reading

Ultra simple SFTP server for Windows

Core FTP mini-sftp-server interface

Was going to test some code the other day which needed to talk to an SFTP server. Stumbled over a small gem which was super simple to use. It’s called Core FTP mini-sftp-server. No installation, no tricky stuff. Just download and run. Great stuff :)