Google::Checkout::General::GCO
Version 1.1.1
use Google::Checkout::General::GCO; use Google::Checkout::General::MerchantItem; use Google::Checkout::Command::CancelOrder; use Google::Checkout::General::Util qw/is_gco_error/; my $gco = Google::Checkout::General::GCO->new( config_path => 'conf/GCOSystemGlobal.conf'); #-- #-- Or you can pass in the merchant id, key and Checkout URL like this #-- $gco = Google::Checkout::General::GCO->new( merchant_id => 1234, merchant_key => 'abcd', gco_server => 'https://sandbox.google.com/...'); my $cart = Google::Checkout::General::ShoppingCart->new( expiration => "+1 month", private => "Merchant private data", checkout_flow => $checkout_flow); my $item1 = Google::Checkout::General::MerchantItem->new( name => "Fish", description => "A fish", price => 12.34, quantity => 12, private => "gold"); $cart->add_item($item1); #-- #-- Checkout a cart #-- my $response = $gco->checkout($cart); or my ($response,$requestXML) = $gco->checkout_with_xml($cart); die $response if is_gco_error $response; #-- #-- print the redirect URL #-- print $response,"\n"; #-- #-- Send a cancel order command #-- my $cancel = Google::Checkout::Command::CancelOrder->new( order_number => 156310171628413, amount => 5, reason => "Cancel order"); $response = $gco->command($cancel); die $response if is_gco_error $response; print $response,"\n";
This is the main module for interacting with the Google Checkout system. It allows a user to checkout, send various commands and process notifications.
Constructor. Loads the configuration file from CONFIG_PATH. If no configuration file is specified, merchant id, key and Checkout server URL must be specified.
Returns the configuration reader used to parse and load the configuration file.
Returns the Google Checkout URL defined in the configuration file.
Returns the diagnose Google Checkout URL defined in the configuration file.
Returns the URL where requests will be sent to.
Same as get_request_url except this function returns the diagnose version of it.
get_request_url
Given a shopping cart (in XML), returns the HMAC-SHA1 / Base64 signature of it.
Given a shopping cart (in XML), encode and return it in Base64.
Given a Google::Checkout::General::ShoppingCart object CART, return the Base64 encoding signature and XML cart. The return value is a hash reference where 'xml' is the XML cart (Base64 encoded) and 'signature' is the Base64 encoding signature.
Google::Checkout::General::ShoppingCart
Sends the shopping cart (Google::Checkout::General::ShoppingCart object) to Google Checkout. If DIAGNOSE is true, the cart will be sent as a diagnose request.
Sends the shopping cart (Google::Checkout::General::ShoppingCart object) to Google Checkout. If DIAGNOSE is true, the cart will be sent as a diagnose request. This method returns both the result and the xml request that was sent to Google Checkout.
Treat XML as a shopping cart and attempt to checkout it. If DIAGNOSE is true, the XML will be sent as a diagnose request. This method is actually used by checkout.
checkout
Sends a command to Google Checkout. COMMAND should be one of Google::Checkout::Command::GCOCommand's sub-class. If DIAGNOSE is true, the command will be sent as a diagnose request.
Google::Checkout::Command::GCOCommand
After you receive a notification, you are expected to send back a response knowledging the notification is properly handled. This method can be used to ensure a valid response is send back to Google Checkout. Since we are communicating over HTTP, this function will return a 200 header first.
This function is similar to send_notification_response except it's used to send back a response after a merchant calculation callback. CALCULATIONS should be an array reference of Google::Checkout::General::MerchantCalculationResult.
send_notification_response
Google::Checkout::General::MerchantCalculationResult
A generic function to send request to Google Checkout. Please note that it's not recommanded that you use this function directly. checkout, command, send_notification_response, etc should be all you need to interact with the Google Checkout system.
command
Copyright 2006 Google. All rights reserved.
To install Google::Checkout::XML::Writer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Google::Checkout::XML::Writer
CPAN shell
perl -MCPAN -e shell install Google::Checkout::XML::Writer
For more information on module installation, please visit the detailed CPAN module installation guide.