A day wasted, knee-deep in Google Checkout’s PHP API

Yesterday, I wasted an entire day trying to integrate Google Checkout into an exciting new web app for my employer, Soapy Co.


Days like these (wasted ones) are particularly frustrating (not to mention, psychologically damaging) and often appear magically when you’re left dealing with somebody else’s code – in this case Google Checkout’s PHP API.

What is Google Checkout?

Here’s a brief introduction to Google Checkout: it is a payment gateway which allows your customers to simply click a button and be taken to Google’s payment page. If they have used Google Checkout before, they can simply press one button to complete the transaction. Retailers can then manage these orders – e.g. marked them as shipped/delivered via Google checkout admin section or via their own site if they use the API. It’s quite similar to Paypal.

Using Google checkout

Google Checkout provides a ‘sandbox’ server (aka a test server) which allows you to test transactions in a very realistic environment but without actually processing any payment. After spending hours upon hours wondering why my sandbox was accepting the test orders as normal but not sending me the ‘callback’ so I could update my database with the transaction information, I discovered from the official developer forums that the sandbox wasn’t functioning too well this week and was probably down yesterday.

Some people (more experienced developers) reading this may groan and wonder why I didn’t come to this conclusion earlier in the day, well it’s a very simple answer: I have an expectation that Google’s products all work perfectly and so when I experienced problems I never questioned that any problem would be Google’s making. I don’t think this expectation is unfounded. Google’s reliability is one of the main reasons behind their monstrous success.

A note about the API code

Whilst working on this exciting new web app, I’ve had to deal with APIs for the first time in my career and I don’t exactly care for them much. Compared to other APIs, Google Checkout is written quite nicely (and had this problem not occurred I dare say, I might’ve conquered it quite quickly) but it is still not commented as well as it could be.

How I like my code to be written

My stance on variable/function/method naming is quite a pedantic one, I loathe naming conventions that lack meaning. I prefer them to make instant sense and I feel I shouldn’t have to find the file where a method is declared and work out what it does in order to understand the code.

$Gresponse->SendAck();

A one line comment above this would help to explain what this was doing but renaming the function (method) to SendAcknowledgement() would be nice too.

but Google’s API does have some well-named methods e.g.

$cart->SetEditCartUrl("http://www.example.com/edit");

Is beautiful in it’s self-explanatory nature, easy to edit and a all-round thoroughly decent chap who you’d be happy to take home to meet the parents.

Summary

To be a web developer is to experience days like these, but the more experienced you become the less often these days occur. What made yesterday’s debacle even more excruciating was the 3 previous days, where I’d experienced nothing short of miraculous progress and every idea I had just seemed to work. However, I was working with my own code on those days.

To be sent crashing back down to earth with a cutting realisation that my programming skills need to be improved dramatically – is not such a bad thing.

3 responses to “A day wasted, knee-deep in Google Checkout’s PHP API”

  1. “…I discovered from the official developer forums that the sandbox wasn’t functioning too well this week and was probably down yesterday….”

    I know exactly how you are feeling. In the past, I have worked with Nochex – trying to integrate that is equally as frustrating as the “test” server behaves completely different to the live and for some reason, keeps sending callbacks for up to 48 hours, every 5 mins (even after your callback script sends back a 401 success).

    I found that with some payment processors, it is better just to test on the live server, paying for items that cost 1p and refunding if possible.

    Anyway, I hope you are feeling better now

    :)

  2. Ah, had the same problem with paypal once. Must say, I prefer $object->long_name_with_underscores_instead_of_camel_case();

  3. Andrew, my preference is camelCase but provided the method name makes sense i.e. its name references what it does. I’m happy.