Instantiates the class
Gregphoto_Service_Google_Checkout
__construct
(string $merchant_id, string $merchant_key)
-
string
$merchant_id: The ten or 15 digit merchant ID assigned by Google
-
string
$merchant_key: The twenty-two character merchant key assigned by Google
Add a new item to the cart
void
addItem
(string $name, string $description, double $price, int $quantity, [string $privateData = false], [string $taxTable = false])
-
string
$name: The part name/number
-
string
$description: The part description
-
double
$price: The unit price of the item in the default currency. May be positive or negative.
-
int
$quantity: The quantity of the item.
-
string
$privateData: Additional data to include with the item. This will not be shown to the user checking out.
-
string
$taxTable: The alternative tax table to be used when computing tax for this item
Adds item elements to the XML for all items added with the addItem method
void
addItemsXML
(DOMElement $itemsNode)
-
DOMElement
$itemsNode: The <items> node of the XML
Creates the cart XML
void
generateXML
()
Returns the HTML checkout button and form code with the cart XML and signature. This should be called last.
string
getHTMLForm
()
Get the HMAC_SHA1 encoded signature required for communicating with Google Checkout
string
getSignature
()
Gets the URL for sending the request to Google Checkout
string
getURL
()
Gets a string representation of the cart XML
string
getXML
()
Implements the HMAC_SHA1 encryption
string
HMAC_SHA1
(string $data, string $key)
-
string
$data: The data to be encrypted
-
string
$key: The key for encryption
For debugging, prints the generated XML to the screen
void
printXML
()
Sets the currency for the cart. The default currency is USD. You do not need to call this unless you are using a different currency
void
setCurrency
(string $currency)
-
string
$currency: The currency code for the cart.
Allows the user to specify a base XML file or string that will be used instead of generating the entire string. The user can then add items to this XML using the addItem method.
void
setDefaultXML
(string $value, [string $type = 'file'])
-
string
$value: The file path or the XML string
-
string
$type: Either 'file' or 'string', defaults to 'file'. If file, the value argument must be the path to the file and the file must be readable by the webserver.
Sets the mode of the operation to use either the sandbox or live Google Checkout site. You only need to call this if using the sandbox as the class defaults to using the live site.
void
setMode
(string $mode)
-
string
$mode: Either 'sandbox' or 'checkout'.
Adds a general shipping rule. You may add multiple rules of which the user may choose one
void
setShipping
(string $name, double $price, [string $type = 'flat'], [array $options = array()])
-
string
$name: The name that will be shown to the user
-
double
$price: The price of this shipping option. This is the price for shipping the entire contents of the cart.
-
string
$type: Available options are 'flat', 'pickup', or 'merchantCalc'. MerchantCalc is not currently operational.
-
array
$options: Adds additional options to the rule - this doesn't currently do anything.
Sets a tax rate for a given state
void
setStateTax
(string $state, double $rate)
-
string
$state: The two letter state code, i.e. 'CA'
-
double
$rate: The tax rate, for example .0875 would be 8.75% tax rate