Making a Better PHP Library for Google Checkout

Google Checkout LogoLong before Google had produced their own [PHP example code](http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP.html) for [Google Checkout](http://checkout.google.com/), I had the need to create my own. It was a library based upon the idea of keeping e-commerce online simple. My goal was to make it possible to implement a server and to persist transactional and order state information in a database with very little code. I would like to think I have succeeded. Take for example, the following code sample:
shoppingCart->privateData[‘discountCode’];
if ($code) {
$discount = Discount::findByCode($code);
$discount->redeem();
}
parent::doNewOrderNotification($request,$response);
}
function doOrderStateChangeNotification($request,$response) {
parent::doOrderStateChangeNotification($request,$response);
if ($request->financialState() == “CHARGED”) {
// do something
}
}
}
?>
Then in a separate file, we’ll call it `server.php`, you would need:
require_once(“lib/checkout.conf”);
require_once(“lib/MySQLGoogleCheckoutServer.php”);
connect_to_db();
$server = new MySQLGoogleCheckoutServer();
print $server->handlePost();
And that’s all you have to do to create a simple server capable of recording a new purchase in your system and then keeping the state of that purchase up to date. The library offers a number of other capabilities as well depending upon your unique purchasing workflow and policies. From this server you can also issue commands to Google, to refund, cancel or archive an order for example.
I am continuing my work to document the library more completely, and to provide a more robust set of examples. In the meantime, I thought others might find this library useful and might also want to help me in its testing and development. The library is available for *free* under an open source license (BSD). [Download](http://code.google.com/p/myphpgooglecheckout/downloads/list) “My PHP Google Checkout” and learn more by visiting its [project homepage](http://code.google.com/p/myphpgooglecheckout/w/list).
If you have questions or need specific [documentation](http://code.google.com/p/myphpgooglecheckout/w/list) please let me know. I will use this feedback to help me prioritize what to work on next.

Advertisements

3 Comments on “Making a Better PHP Library for Google Checkout”

  1. tech news says:

    thank you for sharing this information.

  2. abbas says:

    hi
    thanks for your aerticle.
    where is MySQLGoogleCheckoutServer.php ?
    my site is:
    http://www.mirsoft.net

  3. Dinheiro says:

    Thank you for sharing this information.
    Thanks a lot!


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s