Provides integration with Libraries API (2.x-dev) and a Drush Make script to download the google-checkout-php-sample-code.

This project is aimed at providing basic foundation for integrating your online store with the Google Checkout API using PHP.

Configuration

The Google Checkout integration can be configured by using Drupal variables. For example, the following can be placed in a site's settings.php file.

$conf['google_checkout_merchant_id'] = '...';
$conf['google_checkout_merchant_key'] = '...';
$conf['google_checkout_server_type'] = 'sandbox'; // Defaults to production.
$conf['google_checkout_currency'] = '...'; // Defaults to USD.

Example Usage

google_checkout_load_include('item');
$cart = google_checkout_cart_init();
$cart->SetMerchantPrivateData(new MerchantPrivateData(array('uid' => $user->uid)));
$item = new GoogleItem(t('Something really nice for $17'), '', 1, 17);

...

// Communicate information to GoogleCheckout and redirect user to complete checkout.
google_checkout_cart_redirect($cart);

// Or make button.
echo $cart->CheckoutButtonCode();


/**
 * Handle incoming request from Google Checkout.
 *
 * An acknowledgement response will automatically be sent once the hook has
 * completed.
 *
 * @param $type
 *   The request type.
 * @param $root
 *   The root XML element as a SimpleXML object.
 * @param $serial_number
 *   The serial number of the request.
 */
function hook_google_checkout_request($type, $root, $serial_number) {
  if ($type == 'authorization-amount-notification') {
    $order_number = (string) $root->{'google-order-number'};
    $amount = (int) $root->{'authorization-amount'};

    // Store it or do something cool.
  }
}

Project information

Releases