The code can be found here: 
http://cakegchk.googlecode.com/svn/trunk/google_checkout.php

On Nov 5, 3:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> http://xerophyte.net looks good.
> Thanks friend! you are a lifesaver.
>
> cakegchk did not provide any downloads, probably the code needs to be
> fetched from repository.
> I will try it somtime.
>
> On Nov 4, 7:41 pm, Walker Hamilton <[EMAIL PROTECTED]> wrote:
>
>
>
> > Here's my start to a component. There will eventually be an extended
> > API section and a helper to go along with this, as I am actively
> > working on 3 projects that will be useing and are using google
> > checkout.
>
> > Here's the first one:http://xerophyte.net
>
> > <?php
>
> > /**
> > * Google Checkout Component
> > * @author WalkerHamilton
> > * @license MIT
> > * @version 0.1
> > */
>
> > /**
> > * Download the php docs from 
> > Google:http://code.google.com/apis/checkout/samplecode.html
> > * Drop CheckoutAPIFunctions.php, GlobalAPIFunctions.php,
> > MerchantCalculationsAPIFunctions.php,
> > * OrderProcessingAPIFunctions.php, and ResponseHandlerAPIFunctions.php
> > into a folder named "gcheckout"
> > * in your vendors folder
> > *
> > *       var $components = array('GoogleCheckout');
> > *       var $merchantID = 'merch id here';
> > *       var $merchantKey = 'merch key here';
> > *       var $checkoutTesting = true; //uses sandbox environment if true
> > *       var $continueShopping = 'http://domain.net';//setyour page to
> > continue shopping on
> > */
>
> > /* No Shipping, Ship From, or Taxes have been implemented */
>
> > class GoogleCheckoutComponent extends Object
> > {
> >         var $components = array('Session');
>
> >         var $_merchantID;
> >         var $_merchantKey;
> >         //1 == log to errorlog only, 2 == log to browser only, 3 == log to
> > browser & error log
> >         var $_loggingLevel = 1;
> >         var $_curreny;
> >         var $_testing;
> >         var $_approotdir = APP_DIR;
> >         var $_items = array();
> >         var $_gserve;
> >         var $_continueShopping;
>
> >         /*
> >          *
> >          */
> >         function startup(&$controller)
> >         {
> >                 vendor('gcheckout'.DS.'googlecart');
> >                 vendor('gcheckout'.DS.'googleitem');
> >                 vendor('gcheckout'.DS.'googleshipping');
> >                 vendor('gcheckout'.DS.'googletax');
> >                 vendor('gcheckout'.DS.'googlemerchantcalculations');
>
> >                 vendor('gcheckout'.DS.'googlerequest');
> >                 vendor('gcheckout'.DS.'googleresponse');
> >                 vendor('gcheckout'.DS.'googleresult');
> >                 vendor('gcheckout'.DS.'googlelog');
>
> >                 $this->_merchantID = (isset($controller->merchantID)) ? 
> > $controller->merchantID : '';
>
> >                 $this->_merchantKey = (isset($controller->merchantKey)) ?
> > $controller->merchantKey : '';
> >                 $this->_currency = (isset($controller->currency)) ? 
> > $controller->currency : 'USD';
>
> >                 $this->_continueShopping = 
> > (isset($controller->continueShopping)) ?
> > $controller->continueShopping : 'http://example.org';
> >                 $this->_checkoutTesting = ($controller->checkoutTesting) ? 
> > true :
> > false;
>
> >                 $this->_restoreFromSessionArr();
>
> >                 $this->_gserve = ($this->_checkoutTesting) ? 'sandbox' :
> > 'Production';
> >         }
>
> >         /*
> >          *
> >          */
> >         function setItem($title, $desc, $count, $price, 
> > $merchantItemID=null,
> > $data=null) {
> >                 if($data)
> >                 {
> >                         $this->_items[] = array('title'=>$title, 
> > 'desc'=>$desc, 'count'=>
> > $count, 'price'=>$price, 'data'=>$data);
> >                 } else {
> >                         $this->_items[] = array('title'=>$title, 
> > 'desc'=>$desc, 'count'=>
> > $count, 'price'=>$price);
> >                 }
> >                 return true;
> >         }
>
> >         /*
> >          *
> >          */
> >         function dumpToSessionArr() {
> >                 if(!empty($this->_items))
> >                 {
> >                         $sessR = array($this->_items);
> >                         return $this->Session->write('Google', $sessR);
> >                 }
> >         }
>
> >         /*
> >          *
> >          */
> >         function _restoreFromSessionArr() {
> >                 $sessR = $this->Session->read('Google');
>
> >                 if($sessR==false) {
> >                         return false;
> >                 } else {
> >                         $this->_items = $sessR;
> >                         return true;
> >                 }
> >         }
>
> >         /*
> >          *
> >          */
> >         function getCartItems() {
> >                 return $this->_items;
> >         }
>
> >         /*
> >          *
> >          */
> >         function getCartPreTaxTotal() {
> >                 $total = 0;
>
> >                 foreach($this->_items as $item)
> >                 {
> >                         $total += $item['price'];
> >                 }
>
> >                 return $total;
> >         }
>
> >         /*
> >          *
> >          */
> >         function generateCartButton($data=null, $theitems=array()) {
> >                 $cart = new GoogleCart($this->_merchantID, 
> > $this->_merchantKey,
> > $this->_gserve, $this->_currency);
>
> >                 $counter = 1;
> >                 if(!empty($theitems)) {
> >                         $thisitems = $theitems;
> >                 } else {
> >                         $thisitems = $this->_items;
> >                 }
> >                 foreach($thisitems as $item)
> >                 {
> >                         $varvar = 'item_'.$counter;
> >                         ${$varvar} = new GoogleItem($item['name'], // Item 
> > name
> >                                                                         
> > $item['description'], // Item description
> >                                                                         
> > $item['count'], // Quantity
> >                                                                         
> > $item['price'] // Unit price
> >                                                                         );
> >                         if(isset($item['data']))
> >                         {
> >                                 ${$varvar}->SetMerchantPrivateItemData(new
> > MerchantPrivateItemData($item['data']));
> >                         }
> >                         if(isset($item['id'])) { 
> > ${$varvar}->SetMerchantItemId($item['id']); }
>
> >                         $cart->AddItem(${$varvar});
> >                 }
> >                 // Set the acct. name, etc.
> >                 if($data)
> >                 $cart->SetMerchantPrivateData(new 
> > MerchantPrivateData($data));
>
> >                 // Specify "Return to xyz" link
> >                 $cart->SetContinueShoppingUrl($this->_continueShopping);
>
> >                 // Display Google Checkout button
> >                 return $cart->CheckoutButtonCode("SMALL");
> >         }
>
> >         /*
> >          *      Destruct only automatically saves the cart to the UserÕs 
> > session
> > in php5
> >          */
> >         function __destruct() {
> >                 $this->dumpToSessionArr();
> >         }
>
> >         /*
> >          *
> >          */
> >         function ProcessXmlData($xml_data) {
> >             $dom_response_obj = domxml_open_mem($xml_data);
> >             $dom_data_root = $dom_response_obj->document_element();
> >             $message_recognizer = $dom_data_root->tagname();
> >             /*
> >                 //requests, errors and problem solving
> >              *     <request-received>
> >              *     <error>
> >              *     <diagnosis>
> >                 //Go to google and pay for it.
> >              *     <checkout-redirect> //a redirect
> >                 //Notifications....
> >              *     <merchant-calculation-callback>
> >              *     <new-order-notification>
> >              *     <order-state-change-notification>
> >              *     <charge-amount-notification>
> >              *     <chargeback-amount-notification>
> >              *     <refund-amount-notification>
> >              *     <risk-information-notification>
> >              */
> >                 switch ($message_recognizer) {
> >                         // <checkout-redirect> received //handled in a 
> > predictable manner,
> > so I can integrate this one...
> >                         case "checkout-redirect":
> >                                 
> > $this->_ProcessCheckoutRedirect($dom_response_obj);
> >                                 break;
> >                         case "request-received":
> >                         case "error":
> >                         case "diagnosis":
> >                         case "merchant-calculation-callback":
> >                                 return array($message_recognizer, 
> > $dom_response_obj);
> >                                 break;
> >                         case "new-order-notification":
> >                         case "order-state-change-notification":
> >                         case "charge-amount-notification":
> >                         case "chargeback-amount-notification":
> >                         case "refund-amount-notification":
> >                         case "risk-information-notification":
> >                                 return array($message_recognizer, 
> > $dom_response_obj);
> >                                 break;
> >                 default:
> >                                 $this->log("GCheckoutComponent: Response 
> > '$message_recognizer'
> > unknown.");
> >                                 break;
> >             }
> >         }
>
> >         function _ProcessCheckoutRedirect($dom_response_obj) {
> >             // Identify the URL to which the customer should be redirected
> >             $dom_data_root = $dom_response_obj->document_element();
> >             $redirect_url_list = 
> > $dom_data_root->get_elements_by_tagname("redirect-url");
>
> >             $redirect_url = $redirect_url_list[0]->get_content();
> >             // Redirect the customer to the URL
> >                 $this->controller->redirect($redirect_url);
> >                 exit();
> >         }
>
> >         function _SendNotificationAcknowledgment() {
> >                 $acknowledgement = "<notification-acknowledgment xmlns=\"".
> > $GLOBALS["schema_url"] . "\"/>";
> >                 return $acknowledgment;
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to