|
SettingUpAServer
How to setup a server to receive messages from Google Checkout.
IntroductionBefore a user can submit payments to you, you will need to setup a server that will receive and be responsible for processing messages sent to you from Google. This document will explain how to do that. Step 1. Configure My PHP Google CheckoutFollow the instructions in "Step 1" in SettingUpAShoppingCart. Step 2. Configure Google Checkout
Step 3. Implement a ServerAt the core of My PHP Google Checkout is an abstract class called GoogleCheckoutServer.php. This class defines all of the logic for interfacing with Google Checkout, but it does not define the business logic required by your system. Therefore it leaves several methods unimplemented. You must implement these:
Also found in this library is MySQLGoogleCheckoutServer.php. This implementation of GoogleCheckoutServer stores all incoming messages in a MySQL database. This is a complete implementation of the GoogleCheckoutServer abstract class, but it still does not define any business logic unique to your system. In the example below, you will see how to setup a server that extends the MySQL GoogleCheckoutServer: <?php
require_once("MySQLGoogleCheckoutServer.php");
require_once("Discount.php");
class ExampleGoogleCheckoutServer extends MySQLGoogleCheckoutServer {
function doNewOrderNotification($request,$response) {
parent::doNewOrderNotification($request,$response);
}
function doOrderStateChangeNotification($request,$response) {
parent::doOrderStateChangeNotification($request,$response);
if ($request->financialState() == "CHARGED") {
// do something
}
}
}
?>As you can see, there is very little to implement - all you need to do is provide your own business and routing logic. Step 4. Deploy Your ServerThe final step is to deploy your server. With your server class implemented, now you just need to dispatch messages to it. Create a file called server.php with the following contents. require_once("lib/checkout.conf");
require_once("lib/ExampleGoogleCheckoutServer.php");
connect_to_db();
$server = new ExampleGoogleCheckoutServer();
print $server->handlePost();Now, suppose this server.php file lives at the following URL: http://somedomain.com/checkout/server.php Then you will need to make sure you enter that complete URL into your Google Checkout Integration Settings. |
Sign in to add a comment