My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 03, 2008 by byrnereese
Labels: Featured, Phase-Deploy, config
SettingUpAShoppingCart  
Creating a Google Checkout Button for your web site.

Introduction

The process of submitting a payment to Google Checkout begins with a user clicking a "Buy Now" button. This document describes precisely how to create this button.

Step 1. Setup your config.php

Located somewhere in your search path, but in the ./lib/ directory by default, is a file called "config.php". In order for anything to work with this library, you must edit this file and provide the following:

Finding Your Merchant Information

  1. Login to your Google Checkout seller account.
  2. Click on the Settings tab.
  3. Click on "Integration" in your left navigation.
  4. On this next page you will find the information we are looking for. Look for the following:
    Account information
    Google merchant ID
    6355xxxxxx60346
    Google merchant key
    T6BxxxxxxxxxxxoYRbhg

Step 2. Create Your Button in PHP

Once your config file is setup properly, then creating a button is as simple as:

  1. Instantiate a shopping cart.
  2. Add items to the cart.
  3. Output the cart's button as HTML.

Take a look at the following sample code:

  include("lib/config.php");
  include("lib/GoogleCheckoutCart.php");
  $cart = new GoogleShoppingCart();
  $item = new CartItem("Demo Purchase","Some stuff","1.00",1);
  $cart->addPrivateData("MyAccountID","345");
  $cart->addItem($item);
  $cart->callbackURL = CALLBACK_URL;
  print $cart->button->toHTML($cart);

Sign in to add a comment
Hosted by Google Code