<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="http://www.majordojo.com/projects/FeedManager/atom.xsl" type="text/xsl" media="screen"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php" />
  <link rel="self" type="application/atom+xml" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php" />
  <id>tag:www.majordojo.com,2010://3/tag:www.majordojo.com,2008://3.10645-</id>
  <updated>2010-03-24T06:50:12Z</updated>
  <title>Comments for Making a Better PHP Library for Google Checkout</title>
  <subtitle>A blog about Movable Type, technology, geek-dom, science-fiction and yes, sometimes my personal life.</subtitle>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.261</generator>
  <entry>
    <id>tag:www.majordojo.com,2008://3.10645</id>
    <link rel="alternate" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.majordojo.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=3/entry_id=10645" title="Making a Better PHP Library for Google Checkout" />
    <published>2008-11-03T19:40:33Z</published>
    <updated>2008-11-03T19:47:25Z</updated>
    <title>Making a Better PHP Library for Google Checkout</title>
    <summary>Long before Google had produced their own PHP example code for Google Checkout, 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...</summary>
    <author>
      <name>Byrne</name>
      <uri>http://www.majordojo.com/</uri>
    </author>
    
    <category term="Open Source" />
    
    <category term="Personal Projects" />
    
    <category term="Web Services" />
    
    <content type="html" xml:lang="en" xml:base="http://www.majordojo.com/">
      <![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="Google Checkout Logo" src="http://www.majordojo.com/2008/11/03/google_checkout.gif" width="155" height="60" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></span>Long before Google had produced their own <a href="http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP.html">PHP example code</a> for <a href="http://checkout.google.com/">Google Checkout</a>, 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:</p>

<pre><code>&lt;?php
require_once("MySQLGoogleCheckoutServer.php");
require_once("Discount.php");

class ExampleGoogleCheckoutServer extends MySQLGoogleCheckoutServer {
  function doNewOrderNotification($request,$response) {
    $code = $request-&gt;shoppingCart-&gt;privateData['discountCode'];
    if ($code) {
      $discount = Discount::findByCode($code);
      $discount-&gt;redeem();
    }
    parent::doNewOrderNotification($request,$response);
  }
  function doOrderStateChangeNotification($request,$response) {
    parent::doOrderStateChangeNotification($request,$response);
    if ($request-&gt;financialState() == "CHARGED") {
      // do something
    }
  }
}
?&gt;
</code></pre>

<p>Then in a separate file, we'll call it <code>server.php</code>, you would need:</p>

<pre><code>require_once("lib/checkout.conf");
require_once("lib/MySQLGoogleCheckoutServer.php");
connect_to_db();
$server = new MySQLGoogleCheckoutServer();
print $server-&gt;handlePost();
</code></pre>

<p>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.</p>

<p>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 <em>free</em> under an open source license (BSD). <a href="http://code.google.com/p/myphpgooglecheckout/downloads/list">Download</a> "My PHP Google Checkout" and learn more by visiting its <a href="http://code.google.com/p/myphpgooglecheckout/w/list">project homepage</a>.</p>

<p>If you have questions or need specific <a href="http://code.google.com/p/myphpgooglecheckout/w/list">documentation</a> please let me know. I will use this feedback to help me prioritize what to work on next.</p>
]]>
      

    </content>
  </entry>

  <entry>
    <id>tag:www.majordojo.com,2008://3.10645-comment:147399</id>
    <thr:in-reply-to ref="tag:www.majordojo.com,2008://3.10645" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php"/>
    <link rel="alternate" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php#c147399" />
    <title>Comment from tech news on 2008-11-16</title>
    <author>
        <name>tech news</name>
<!--        <uri>http://www.zahipedia.com</uri> -->
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.zahipedia.com">
	<![CDATA[<p>thank you for sharing this information.</p>
]]>
    </content>
    <published>2008-11-17T06:21:20Z</published>
    <updated>2008-11-17T06:21:20Z</updated>
  </entry>

  <entry>
    <id>tag:www.majordojo.com,2008://3.10645-comment:170526</id>
    <thr:in-reply-to ref="tag:www.majordojo.com,2008://3.10645" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php"/>
    <link rel="alternate" type="text/html" href="http://www.majordojo.com/2008/11/making-a-better-php-library-for-google-checkout.php#c170526" />
    <title>Comment from abbas on 2010-03-23</title>
    <author>
        <name>abbas</name>
<!--         -->
    </author>
    <content type="html" xml:lang="en" xml:base="">
	<![CDATA[<p>hi
thanks for your aerticle.
where is MySQLGoogleCheckoutServer.php ?
my site is:
<a href="http://www.mirsoft.net" rel="nofollow">http://www.mirsoft.net</a></p>
]]>
    </content>
    <published>2010-03-24T06:48:02Z</published>
    <updated>2010-03-24T06:48:02Z</updated>
  </entry>

</feed>
