File: example.php

Recommend this page to a friend!
  Classes of Vagharshak Tozalakyan  >  Google Checkout Button  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: How to use
Class: Google Checkout Button
Generate Google Checkout cart submission forms
Author: By
Last change: foo
Date: 13 years ago
Size: 3,142 bytes
 

Contents

Class file image Download
<?php

/*

BEFORE TESTING THE CLASS...

1. You need to create two test accounts in the Sandbox:

- Customer test account at http://sandbox.google.com/checkout
- Merchant test account at http://sandbox.google.com/checkout/sell/

Please adhere to the following guidelines when setting up your test accounts:

- Skip any sections that ask for your bank account information. Since the Sandbox
does not process billing or payments, this information is not necessary when you
are testing your implementation.
- Enter any name and address as long as the State field contains a valid two-letter
abbreviation for a U.S. state and the Zip Code field contains a five-digit or
nine-digit zip code. (You do not need to enter the correct zip code for the address.)
- Enter any 10-digit phone number for the Phone Number field.
- Use VISA as card type, 4111 1111 1111 1111 as card number and 123 as CVC.


2. Sign in to your test merchant account at https://sandbox.google.com/checkout/sell
to locate your Merchant ID.

After signing in to your account, click on the Settings tab. Then click on the
Integration link on the left side of the page. Your 10- or 15-digit Merchant ID
and your Merchant Key will both be listed under the Account information header.

Under the Shopping cart post security header, uncheck the box to allow your account
to use API requests with name-value pairs. After removing the check from the checkbox,
click the Save button to save your settings.

Note: You must confirm that you will post unsigned shopping carts for your sandbox
account and your production account.

Additional information can be found at
http://code.google.com/apis/checkout/developer/google_checkout_html_api.html

*/

// Include class source
require_once 'class.GoogleCheckoutButton.php';

// Create class instance using merchant ID, server type and currency
$gch = new GoogleCheckoutButton('123456789012345', 'sandbox', 'USD');

// Add shopping cart item(s) by name, description, quantity and unit price
$gch->addItem('Item 1', 'Description of item 1...', 5, 12.95);
$gch->addItem('Item 2', 'Description of item 2...', 1, 10.55);
$gch->addItem('Item 3', 'Description of item 3...', 2, 9.00);
$gch->addItem('Item 4', 'Description of item 4...', 1, 222.00);

// Optionally define discount(s) by name, description and amount
$gch->addDiscount('Discount', 'Description of discount...', 20.00);

// Define shipping method(s) by name, description, price and optional shipping region
$gch->addShippingMethod('Shipping method 1', 'Description of shipping method 1', 10.75, 'ALL');
$gch->addShippingMethod('Shipping method 2', 'Description of shipping method 2', 10.25, 'ALL');
$gch->addShippingMethod('Shipping method 3', 'Description of shipping method 3', 10.15, 'FULL_50_STATES');
$gch->addShippingMethod('Shipping method 4', 'Description of shipping method 4', 6.15, 'CONTINENTAL_48');

// Optionally define a tax rate for specific US state
$gch->setTaxRate(0.085, 'CA');

// Finaly display a button that submits shopping cart to Google
$gch->showButton('large', 'white', false, false);

?>


For more information send a message to info at phpclasses dot org.