the fast, reliable localhost tunneling solution


Downloadable receipts

By Bjarni RĂșnar 2012-10-12, 19:22

A while ago, one of our esteemed paying customers asked us if we could provide him with proper receipts for his purchases. Due to a series of misunderstandings, I had been convinced that this was actually already taken care of by our payment processor, which I eventually realized was not actually the case.

Oops. Rookie mistake!

So this week I spent some time teaching our order processing systems to generate nice PDF receipts and make them available for download from our users' account pages. As we have records of all our previous transactions, I will be generating receipts back in time for all of our customers and they should become available for download on Monday or Tuesday at the latest.

How it works

For the techies in the crowd, here is a brief summary of how the system works:

  1. Our payment processor POSTs a notification to pagekite.net that a payment has been accepted.
  2. Details of the order are written to a file as the account quotas are updated.
  3. The receipt generating process notices the new file and uses the contents to customize an ODT template.
  4. The customized ODT file is converted to PDF by unoconv.
  5. The PDF is made available for download and the user's account history is updated.

The most interesting part of this process was writing the tool which customizes the ODT template. This turned out to be a relatively trivial task since the Open Document format is actually just a bunch of XML files in a ZIP container - both very easy to manipulate with code.

The most annoying part, was that unoconv seems to be relatively unstable and prone to randomly crashing. So much of the work involved was making sure the batch processing systems were robust enough to notice failures and retry. This is also the main reason there may at times be a slight delay between accepting an order and the receipt becoming available for download.

Please feel free to let us know if you feel the new receipts are inadequate in any way.

Comments

None, comments are closed.

The Blog

Welcome to the PageKite blog!

Here we write about anything and everything to do with running the service, building a company, open-source, privacy online... you name it.

But mostly it's about PageKite.

Other venues