My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Documentation  

Featured
Updated Feb 4, 2010 by jacob13moon@gmail.com

PHP Sample Code for Google Checkout

File structure and function

There are two folders and a log file in the top level directory of google-checkout-php-sample.

1. "demo" directory - This contains two files cartdemo.php and responsehandlerdemo.php

  • cartdemo.php
    • This file demonstrates the steps required to add items, shipping, taxes and merchant-calculations to the cart before it is posted to the Checkout server. There are three use case functions defined with different settings for shipping and taxes along with different button usages.
  • responsehandler.php
    • This file will be used to handle the notifications, callbacks and order processing steps. The path for this file must be specified in the merchant's API callback URL in Settings->Integration of the merchant's seller account. This file can be used as is and modified by the merchant as per their business workflow details. Some of the intial steps performed in this file include collecting the XML response, request that has been received and get a parsed result in a PHP associative array for easy accesibility (For details of parse output refer xmlparser.php which has an example of how an XML maps to the object). Order processing can be done using the SendProcessOrder(..) type of methods provided in googleresponse.php. Some sample order processing command invocations have been provided as comments in the code

2. "library" directory - This contains the classes defined to describe the API structure so as to easily define and add XML entries by defining objects of these classes.

  • googlecart.php
    • This is the main class which must be instantiated to post a cart. It requires a merchant ID and key to be set and there is an option to specify which server is to be used for the transactions (Sandbox or Production). It also has methods to add items, shipping options, tax options and merchant-calculation details.
  • googleitem.php
    • This class is instantiated for every item to be added to the cart. It requires the item name, description, price and quantity to be specified.
  • googleshipping.php
    • This class is instantiated for every shipping option that is to be added to the cart. It requires the shipping name type an price to be specified. Other methods allow specification of the shipping restrictions.
  • googletaxrule.php
    • This class is used to define all tax rules for the tax tables. These may be rules for default or alternate tax tables. Methods have been provided to add states and zip patterns for the tax rules.

  • googletaxtable.php
    • This class is used to aggregate all the defined tax rules to define a tax table. This may be a default or alternate tax table identified by the "type" value.

  • googleresponse.php
    • An instance of this class is created in the responsehandlerdemo.php. This again requires the merchant id and merchant key to be specified. There are methods provided to send all the different order processing commands. All notifications are parsed and the merchant can take required action when a particular notification is received.
  • googleresult.php
    • This class is used for merchant-calculations and is invoked for each result in the merchant-calculations-result sent from the merchant in response to a callback.

  • googlemerchantcalculations.php
    • In order to process merchant calculations, an instance of this class is created. It is used to aggregate merchant results and respond with the XML response for the callback.

  • "xml-processing" directory
    • xmlbuilder.php
      • This class generates XML and consists of "push" and "pop" methods to add open and close tags respectively. This is used internally by the library classes to generate XML file for posting carts.
    • xmlparser.php
      • This class parses XML documents using the SAX parser and is compatible with PHP v4 and 5. It converts them to DOM form returning the XML data in a PHP associative array. This is used internally by the library classes to parse XML requests and responses that are received from the Checkout server.

3. googlemessage.log: The log file records all the notification and order processing commands that are sent and received and can be useful information for debugging purposes.

If you're looking for the documentation of the earlier version of the PHP sample code, visit http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP.html

Comment by davidgut...@gmail.com, Aug 6, 2007

A nice feature in this documentation would be a quick reference about what has to be modified to get the demo code working. For example, I got the standard checkout request to work after I put in my sandbox ID & key, but I'm having no luck with server 2 server, so a reference to which areas need editing in the code provided would save this novice a lot of time.

Comment by donmub...@gmail.com, Aug 10, 2007

someone please explain what server 2 server is all about

Comment by frooglem...@gmail.com, Aug 18, 2007

server 2 server: the unofficial term for 2 web servers communicating between each other. IE your web site server and the server at Google Checkout.

If you have problems then check with your web host that communication to google's urls is possible at file_open level (or curl comms level) as most web hosts turn off this commuication by default. Strange but true but they will sort it for you!

:)

Comment by frooglem...@gmail.com, Aug 18, 2007

server 2 server: the unofficial term for 2 web servers communicating between each other. IE your web site server and the server at Google Checkout.

If you have problems then check with your web host that communication to google's urls is possible at file_open level (or curl comms level) as most web hosts turn off this commuication by default. Strange but true but they will sort it for you!

:)

Comment by frooglem...@gmail.com, Aug 18, 2007

server 2 server: the unofficial term for 2 web servers communicating between each other. IE your web site server and the server at Google Checkout.

If you have problems then check with your web host that communication to google's urls is possible at file_open level (or curl comms level) as most web hosts turn off this commuication by default. Strange but true but they will sort it for you!

Comment by prash...@gmail.com, Sep 25, 2007

Its really strange, Google has implemented Google checkout but lots of developers facing problem to integrate it successfully with response handler. I don't know why its not working fine for me as well. Can anyone pls explain what needs to do for taking response from Google server...?

In my Integration section i gave the callback url but still its showing Authentication problem.. what does this mean!!!!

Prashant Agarwal http://prashcom.blogspot.com

Comment by prash...@gmail.com, Sep 25, 2007

Its really strange, Google has implemented Google checkout but lots of developers facing problem to integrate it successfully with response handler. I don't know why its not working fine for me as well. Can anyone pls explain what needs to do for taking response from Google server...?

In my Integration section i gave the callback url but still its showing Authentication problem.. what does this mean!!!!

Prashant Agarwal http://prashcom.blogspot.com

Comment by prash...@gmail.com, Sep 25, 2007

ah ha... its google i can't belive this???

i tried to do one post but because i got server error so i submitted too many times and when i refreshed the page.. its coming too many times...

hey Google Guys!!! what are u doing...? If u don't have time to manage Google Checkout then give it to me.. i will do for u ;)

Comment by artis...@gmail.com, Oct 5, 2007

added carrier calculated shipping to this code if anyone wants it post a message.

Comment by james.le...@mac.com, Oct 10, 2007

I would like to second the request for a guide on what needs to be modified to get this going.

After spending a couple of days working with the code, I'm not very far in my integration process. I like that the documentation says responsehandler.php puts "a parsed result in a PHP associative array for easy accesibility." Um. What's the array?

Comment by BLYZZARD...@gmail.com, Oct 26, 2007

You know, as a novice integrating API's into PHP, it would be nice if the had a sample.php page for download with one example item, laid out in a table with the an 'Add to cart' link, a 'Qty' box or a 'Qty' drop down box so they could add more than one at a time. With the proceed to checkout button at the bottom so that we had a working template to build from and try adding adaptations. Just a thought.

Comment by gspe...@cityamigo.com, Oct 27, 2007

This is soooo much cleaner than PP... thanks google.

Comment by sherifma...@gmail.com, Nov 1, 2007

is there any documentation for novive php developers

sherif

Comment by thegempa...@gmail.com, Nov 16, 2007

Hi, Sorry to be sooo dumd :( but I know almost nothing about PHP ...... and I am trying to integarted google shopping with osc shopping cart developed in PHP.

I saw all documents .... can someone tell me 'WHERE' to upload which php or xml file .... I mean which folder to use for what file.

Thanx.

Comment by j...@nachnach.com, Nov 26, 2007

Slight problem, I'm trying to test this out, but it keeps asking for a Username and Password???

Comment by balasent...@gmail.com, Dec 1, 2007

Hi

Is there a way to generate refund notifications for all past transactions?

Comment by pragyabc...@gmail.com, Dec 6, 2007

is there any way to integrate the google checkout procedure within one site?

Comment by shahdeve...@gmail.com, Jan 6, 2008

i used google check out with level 2 for my client in php.the code work fine in other servers but on the client server it give file save as option when google check out button is clicked.My client server install php 5 and Server API are CGI.cURL etc are also

enable with open ssl.please required help for this isue how to resolve this issue.upto mine some server configuration is required but i am not a linux etc oproficient so please tell in brief what to do.

Comment by blogsche...@gmail.com, Feb 21, 2008

I saw in the documentation that there was a new version out uploaded on feb 13th reffered to as 1.25c which was supposed to have version: 1235. I downloaded it and the zip made a folder called 1.25b, which had @version: 1234 2007-09-25 in it. Please fix and notify me when changes are made.

Comment by Izono...@gmail.com, Mar 13, 2008

I'm reading these comments trying to work whether it is worth trying to get this working on my website. Two things are obvious:-

1. THERE MUST BE A SAMPLE APPLICATION

2. ..................................GOOGLE AREN'T LISTENING!!

3. THERE MUST BE A SAMPLE APPLICATION

4. ..................................GOOGLE AREN'T LISTENING!!

5. THERE MUST BE A SAMPLE APPLICATION

6. I'm wasting my time here because ..............GOOGLE AREN'T LISTENING!!!

Comment by check...@quebix-solutions.co.uk, Mar 27, 2008

WHY WOULD YOU TRY SOMETHING IF YOU DONT KNOW WHAT YOU ARE DOING. GOOGLE ARE NOT IN THE WRONG FOR YOUR MISFORTUNES.

I'm an exprienced PHP developer with years of exprience .... took me 10mins. THE API is there READ IT for X-sake. IT'S NOT SIMPLE BECAUSE IT'S BEEN DEVELOPED CORRECTLY LIKE ANY OTHER API OUT THERE.

YOU ALL WANT KNOWLEDGE FOR FREE AND THE SAD THING IS THAT YOU DON'T UNDERSTAND WHAT YOU ARE DOING....WHY SHOULD GOOGLE LISTEN WHEN THERE IS TONNES OF INFO AND DOCUMENTATION. I'VE MADE AN OBJECT OF THE INFO THAT DOES IT ALL AND IT WAS SO SO SO EASY....ALL YOU HAVE TO DO IS READ...THAT'S ALL THAT'S REQUIRED.

EAMON STRAUGHN

Comment by Joroja...@gmail.com, Apr 4, 2008

is there any things knows about ipn just like paypal? does google checkout have this?

Comment by billskip...@gmail.com, Apr 8, 2008

Getting started to add GoogleCheckout? to your own cart, with PHP... (you will need to get a merchant ID and key before you can get serious). If you are trying to add a 'submit cart' button (ie you already have a cart program and you want to pass the order through to GoogleCheckout? for payment - as you probably do to PayPal? already), look at the cartdemo.php program. Basically you have to create a 'google-cart' object, then for each item you have to create a 'google-item' object and add the google-item to the google cart.There is then a few more bits to do (tax, shipping, etc) and then you create a checkout button.

Comment by nicholas...@gmail.com, Apr 9, 2008

How does this thing work?

This is a lot of code from google which makes OBJECTS into XML and sends it with CURL. The Google API works with XML (though there is another version which uses &var=value. http talk. (and another with Very Easy HTML form)

The main page (i use) (DIGITAL CART) uses under-functions and objects and classes. Mostly, anything called will require and initiate functions in the level below - for example, DIGITALCART requires GOOGLECART which requires GOOGLEREQUEST. GOOGLECART will use objects and functions in GOOGLEREQUEST on behalf of DIGITAL CART.

There are quite a few "turned off" functionalities in this - so look through it before you make anything... !

each (main) page has at the top - google merchant key, sandbox (or not) and currency. Which need to be set correctly.

You'll need CURL installed and have the google-response viewable from the internet.

WHAT DID I CHANGE? to make it work? (it's a very complex system - it took me 2-3 days to read the help and the code... however it is Very Flexible (much more than PayPal?).

- put merchant ID in top of main pages, (in demo) - to get ResponceHandler? to work you have to enter its address in merchant account (tools)

- i also had to move $Gresponse->SendAck?(); from line 164 to 203 - if you want the script to CHARGE the card (it defaults to just auth it and you manually charge) un comment $Grequest->SendChargeOrder?($data[$root]['google-order-number']['VALUE'],''); on 176.

i used digital cart - which didn't require tax or shipping things, but you still have to enter product details. (it only uses item_1 and item_2 for display - after each they are "pushed" into the object.

>> does anybody else think that Functions and Objects as 'easy to understand' code slightly back-fires when you have levels of functions and functions and objects - making it much more complicated to follow a process-trail. (than straight 'no frills' code would be).

[ much like CSS back-fires on 'easy to use' as you usually end up with a 1000 line file for specifying all possible permutations of style (as styles cannot be treated as components like lego bricks)

Good luck, enjoy. (i wrote this as the comment I would have liked 3 days ago)

Comment by billskip...@gmail.com, Apr 9, 2008

Hi nicholasamps, When you implemented ResponseHandler? did you have to set up an SSL domain? I read somewhere that you needed to. Rgds, Bill

Comment by teddyb...@gmail.com, Apr 25, 2008

how to access the responsehandlerdemo.php

it keep display Invalid or not supported Message

Comment by nicholas...@gmail.com, May 1, 2008

implementing ResponseHandler?... its says you need SSL - but it worked (for me) without - though make sure you CHECK the web-page-interface of the merchant account - there are A FEW KEY stumble-blocks there. (in the 'imlimentation' tab in 'settings')

Comment by nicholas...@gmail.com, May 2, 2008

PREVIOUS POST INCORRECT (by me). Response handler SANDBOX is fine without SSL - but Production needs it.

Comment by gcttestb...@gmail.com, May 7, 2008

we are using responsehandler.php for fetch the values from google thanks page. But got the error message "Invalid or not supported Message". Even we changed the setting in .htaccess and ..htpasswd file. google error file shows the same thing "Invalid or not supported Message"... Is any code modification required in responsehandler.php file or else? Please guide us. ......

We are using the Sample PHP code for integration of Google Checkout with the merchant site v1.2.5 The values send through cartdemo.php file to google checkout page.

Comment by matt%axi...@gtempaccount.com, Jul 31, 2008

i had a web designer build a website for me and they used the sandbox version, but when they uploaded the files they didn't put it into production mode. Can someone tell me exactly where to input my merchant id and key into the .php files?

Comment by mangal.v...@gmail.com, Aug 14, 2008

Can anyone pls explain what needs to do for taking response from Google server...?

Comment by i...@ontop.co.uk, Aug 19, 2008

for all of you having problems this should solve them

http://code.google.com/p/google-checkout-php-sample-code/issues/detail?id=36

Comment by arba...@gmail.com, Sep 28, 2008

So I'm having a very unusual problem. Everything is fine on my testing server (MAMP) but for some reason, anything that uses the google checkout library doesn't work. Even require_once-ing the files halts the execution of the script. I've tried everything relating to messing with the include paths and disabling my autoload, but I still can't get it to work. My production server has cURL, php5, apache2, etc (just like MAMP). What could be wrong?? Thanks, Austin.

Comment by i...@whoopie.net, Oct 9, 2008

Could all those super techies who think this is easy STOP SHOUTING and post a simple working example of a callback script that gets the info from checkout and puts it in a mysql database and updates it whenever checkout does an action! That is all quite a lot of people need right now so that they can do invoice printing etc... (cause you cant do that easily with checkout!)

Comment by edoceo....@gmail.com, Oct 21, 2008

Checkout samples were awesome! Thanks Google, server2server works without issue on my host! Much easier than PayPal?! Only took one hour to integrate my custom cart with the checkout process. Awesome! Thank you!

http://edoceo.com/

Comment by jmil...@trafficeducation.net, Oct 31, 2008

Our SSL site setup works just fine with this software; I'm past initial setup and functionality... it's all good. And I can see the plethora of lovely xml returned from Google regarding the transaction in the log. I have spent an entire work day trying to figure out integration (time is money in web development as I'm sure you know and I can't afford much more) but I'm just trying to integrate the response with our php/sql/database... I'm having the hardest time getting my local Google files to do ANYTHING based on the xml response.

At the very least I'd like to run a sql statement when, let's say, the new-financial-order-state is returned as "CHARGED". I've tried putting conditionals in the new-financial-state switch under case 'CHARGED': no dice. I've tried adding a conditional in the ProcessOrderStateChangeNotification?() function: no dice. Can anybody point me in the right direction of a functioning PHP/sql integration example? I just can't find any documentation and I'm going 2 days on this GC setup. Thanks to all who can help.

Comment by inventma...@inventmagic.com, Nov 7, 2008

Is there any chance this could be more complex? I have very little I am trying to accomplish, I want to get sent a variable when a payment is complete that's it. either the payment is complete and they have a membership or the payment failed and they cannot access my site. I dont have the time to go through all this complex code as a solution to my simple problem. does google have a simple passthrough variable somewhere I can use without all this extra baggage.

www.mysite.com/Process_Page?.php?payment_Complete=true,id=12345

Please tell me this is available somewhere.

Comment by jessie.j...@gmail.com, Nov 17, 2008

SSL certificate installed on your server for level 2 integration.

My Question: Is the SSL certificate installation necessary? How to intall SSL.

My plateform: winowsXP + mysql5.X + php5.X + apache

Comment by kb.ba...@gmail.com, Jan 1, 2009

Nice documentation:)do you have a date on the new release?

Baiju http://www.baijukb.com

Comment by awevtrad...@gmail.com, Jan 17, 2009

Jessie.java, It looks like the sandbox (test server) does not need an SSL certificate, while the production server does.

I suggest you read the apache manuals, it is possible to have your server generate it, you just have to work your way through a few steps.

Comment by unixdarwin@gmail.com, Jan 22, 2009

Why the sample-code doesn't have function set serial number of the notification? I need it to response for google checkout handshake so that I had modified GoogleResponse?.php just added

function setSerialNumber($num)

    { 

    $this->serial_number = $num; 

    } 

... 

function SendAck??($die=true) {

    $this->SendOKStatus(); $acknowledgment = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . 

    "<notification-acknowledgment xmlns=\"" . $this->schema_url . "\" serial-number=\"" . $this->serial_number . "\"/>"; 

    $this->log->LogResponse??($acknowledgment); if($die) { 

    die($acknowledgment); 

    } else { 

    echo $acknowledgment; 

    } 

    }
Comment by inventma...@inventmagic.com, Jan 27, 2009

Please someone tell me what I am doing wrong...All I want to do is add

<merchant-private-data> whatever data I need goes here </merchant-private-data>

I have used the $cart->SetMerchantPrivateData?($data) and all the other functions in the cart class related to merchant data....I get nothihng in the XML tag <merchant-private-data> google sends it back to me without this tag unless I define the value in the googlecart.php class file... Please any suggestions would be greatly appreciated... here is sample code

$cart = new GoogleCart?($merchant_id, $merchant_key, $server_type,$currency);
$cart->SetMerchantPrivateData?(
new MerchantPrivateData?(array("User_Id?" => "ABC123")));
echo $cart->CheckoutServer2ServerButton?('digitalCart.php');

no errors come up but I dont get the values sent back to me....

Comment by riyesh...@gmail.com, Jan 30, 2009

can u help me

For what API callback URL is used? after a customer place order from my web page how can i execute one of my php file Please help me F1 ,F1,...

By riyesh07@gmail.com

Comment by ejge...@gone1981.com, Feb 9, 2009

I agree with older post. The documentation is all over the place and hard to follow. I work with api's for payment processing all day long with some of the largest processor's in the world. They always have -- Request --> Response along with required fields and size of fields.

I have been searching through this mess for a little over an hour now with no avail. Has anyone found a documentation in this site that can provide this? Ok. I see that there are a bunch of methods. Extremely unclear. ehem.. no comments. " check...@quebix-solutions.co.uk, "

Request->> url

fields returnURL
Response->>
fields

Comment by rreu...@fspp.com, Feb 10, 2009

Google has taken the time to answer all of these complaints. The answers are all at http://google.com. Type "php 101" into the long rectangle in the middle of the screen and then click "Google Search" with your pointing device. If you still have problems, consult your jr. high guidance counselor about different career options.

Comment by iprustam...@gmail.com, Feb 22, 2009

Really nice examples! Thank you, they're very simple to understand and modify!

Comment by iprustam...@gmail.com, Feb 22, 2009

inventma...@inventmagic.com

Firstly, you should set your API callback URL at Merchant's account (Settings->Integration) to 'http://yourdomain/demo/responsehandlerdemo.php'

Then, try to insert this debug code in responsehandlerdemo.php which writes all received information during transaction before " switch ($root) { ":

$f = fopen(dirname(FILE)."/log.txt", "a+"); fwrite($f, "\nROOT:\n".$root."\nData:\n".print_r($data, true)); fclose($f);

switch ($root) {

Then, open log.txt file at your server directory and check Google's response information.

Comment by velk...@gmail.com, Apr 19, 2009

Maybe someone should TRY the demo code before posting it live. No help at all!

Comment by mayask...@gmail.com, Jun 3, 2009

OK GUYS HELLO THERE THIS IS A SOLUTION WITH A DOWNLOADABLE FILE !!!! NOTE

this works and I have used it on 2 websites now! ALL THIS DOES IS gets the response from google and stuffs the data into the mysql database

http://www.whoopie.net/downloads/checkout-example.zip

Contains 1)SQL commands to create the tables for the database 2)my version of the responsehandler file - this needs some amends - read the comments in the file! basically database info merchant key and id bit and thats it!

I really hope this helps - also keep checking out the site as a free cms system that has an online shop that integrates with checkout seamlessly is on the way - why? - why not?

Comment by mayask...@gmail.com, Jun 3, 2009

Instructions for above 1) create your database (use the structure in the file I provided) 2) change the database information in the whoopie_checkoutex.php file 3) if going straight for production change the merchant id, key, currency and set the 'sandbox' to 'production' 4) upload the php file to some secure webspace (or not if in sandbox mode) 5) put the URL in the checkout callback field in the google checkout backoffice 6) make sure its set to XML in the checkbox below it 7) under the advanced option bit below that tick the tow ones that relate to phone numbers if you want to get those 8) now build your pages to read the database (pretty simple, but i can provide an example of that if required

all the best

Iain

Comment by info%sky...@gtempaccount.com, Jun 5, 2009
Comment by mayask...@gmail.com, Jun 8, 2009

whoops! try this go to http://www.whoopie.net/

there is a link on the homepage

Comment by mayask...@gmail.com, Jun 8, 2009

I am currently modifying as I rather stupidly didnt allow for people calles o'shea did it very quickly and forgot to make the script deal with quote marks in the name (anyone with basic MySQl skills can fix this as it's now pretty obvious where things are hgappening and fixing the sql should be easy!

Comment by reneholl...@gmail.com, Jul 5, 2009

The path for this file must be specified in the merchant's API callback URL in Settings->Integration of the merchant's seller account.

How can you override this path requirement in the merchant's API callback setting? I have a number of sellers that use checkout and these sellers also sell on a number of different sites... So, how can these sellers input each sites callback requirement. It seems that sellers are limited to one site and one API callback....

Comment by vikasbha...@gmail.com, Jul 12, 2009

hi mayasky76, I want one help from you.. I am using the scrip and php code provided by you on http://www.whoopie.net/ but i am facing on problem in that. Actually i have local buyer id which i stored in session variable. now when we are inserting data through responsehandlerdemo.php into table WPY_GOOGLE i want to insert the buyerid also which is in session. but i am unable to get that value from session. I dont want is the exaclty the problem and where is it?? pls help me i am stuck in this problem

thanks in advance vikas

Comment by gcheckou...@gmail.com, Sep 22, 2009

I have simple website and i want to integrate google checkout. I want the credit cart box and billing info on my website and when i press submit, i want to use the google checkout to check all the conditions and get me responce back, just like aurthorize.net.

How can i do this?

Comment by craig.le...@gmail.com, Dec 8, 2009

For anyone who was having trouble getting responsehandler.php to charge the card once the "Chargeable" state is sent, I had to modify the sendAck (acknowledgment) method call: $Gresponse->SendAck?();

I instead changed it to be: $Gresponse->SendAck?(FALSE);

The reason is because SendAck?() takes a $die variable that defaults to true. I don't wholly get it, but if it dies, then the response handler file will stop processing, and it won't even do the switch for $new_financial_state.

Comment by craig.le...@gmail.com, Dec 8, 2009

As another note, a lot of my problems were solved when I realized that require_once() functions in a number of files (as well as the RESPONSE_HANDLER_ERROR_LOG_FILE and RESPONSE_HANDLER_LOG_FILE variables in the responsehandler.php file) were not using the proper path on my server. Either due to configuration problems or some other means of my own incompetence, the ini_set() function was not giving the proper path.. So log files were not being generated and the XML parser files were not be included (required, really) correctly either.

Comment by quilting...@momsmagicthimble.com, Jan 18, 2010

I NEED HELP...

I have been trying like the dickens to get this sample to work. There is only one thing in the process I cannot figure out and maybe you all can help. In one of the steps it states "You'll need to configure basic authentication on this server to accept your Merchant ID and Merchant Key as a login and password. You may wish to ask your hosting provider or review your server instructions for configuration details, as they will differ for each server software" and my problem is I cannot figure out how to do it. I have even spoken to my host admins and they are clueless. Can someone tell me HOW to create the basic authentication on my server? Is it simple? Like I said this seems like my stopping point because my Integration Console keeps giving me a 404 and I believe it stems from this step.

I have SSL enabled.

PLEASE HELP!!!

dbmdude

Comment by carazoo...@gmail.com, Feb 15, 2010

Thanks for such a nice information.

http://www.carazoo.com/

Comment by atic...@gmail.com, Feb 16, 2010

Thanks to All

Comment by atic...@gmail.com, Feb 16, 2010
Comment by focusby...@gmail.com, Apr 1, 2010

HI, Really its good but I am not getting How to handle responces . FocusBytes

Comment by texasdd...@gmail.com, Apr 11, 2010

I endorse the application guidelines on what should be changed to go. http://www.texas-defensivedriving-online.com/

Comment by phil.rad...@researcha.com, Jun 10, 2010

Love that the comment about mismatching directory version inside the bundle from Feb 21, 2008 still applies. Meanwhile, some bug fixes:

In gc_xmlbuilder.php, the four instances of htmlentities() should be htmlspecialchars(), otherwise it'll put undefined entities into the XML. (The third one should additionally specify ENT_NOQUOTES.)

In googlecart.php, if you put the 'if(!empty($item->digital_url))' check around only the line setting the $item->digital_url element, instead of the whole block, then you can e.g. specify description for URL downloads - much better than the stock 'Click here to ...' yellow box message...

Comment by Ron9....@gmail.com, Jul 15, 2010

I have simple website and i want to integrate google checkout. I want the credit cart box and billing info on my website and when i press submit, i want to use the google checkout to check all the conditions and get me responce back, just like paypal do direct pay.

How can i do this? In what demo i can test this ?

Comment by lfine...@alzamorainc.com, Jul 22, 2010

I need to integrate an affiliate script to google checkout. Does anyone have the widget/script to achieve it? Thanks kidnly in advance for all your support!

Comment by viva.pri...@gmail.com, Oct 4, 2010

I have completed the integration, thanks for the great code.

Just one question, how do I get the transaction fee into the database? According to the docs on Google it should be this -

$data[$root]['latest-charge-fee']['total']['VALUE']

Not sure why, but it's not working?

Any ideas?

Comment by rjv...@riverblindness.org, Jan 30, 2011

I am a surgeon with decades of experience. I could take out your appendix in ten minutes. There's LOT's of documentation.

Nonetheless, one sample page of code from an experienced PHP programmer could help me a lot. Some day, perhaps i'll return the favor.

Comment by ajqu...@gmail.com, Feb 6, 2011

The response handler doesn't work in the sample. I believe it has to do with the Ack part of the script. I think it kills the whole thing.

Comment by astrolea...@gmail.com, Mar 17, 2011

ack is missing serial number, this seems to be an issue with V2.5API (perhaps others?)

Comment by sim...@ringalpha.com, Apr 18, 2011

it can be useful to search on http://github.com for working examples

Comment by bvina...@gmail.com, Apr 28, 2011

I am getting error

We encountered an error trying to access your server at http://www.xyz.com/checkout/demo/responsehandlerdemo.php -- the error we got is java.io.IOException: Error 'TIMEOUT' connecting to url 'http://www.xyz.com/checkout/demo/responsehandlerdemo.php'.

Can someone pls. tell why this error is getting generated....

Comment by ChrisTre...@gmail.com, May 11, 2011

SERIOUS BUG IN SAMPLE CODE 1.3.1

Effects server-2-server posting.

Symptoms: The redirect URL is returned empty or blank on a cart submission even though the status code returns 200 (a successful cart submission).

Cause: GoogleRequest?.SendReq? function

For details of the bug and a fix see:

http://code.google.com/p/google-checkout-php-sample-code/issues/detail?id=60

Comment by sumitpan...@gmail.com, Sep 15, 2011

What steps will reproduce the problem? 1. requested url is https://sandbox.google.com/checkout/view/buy?o=shoppingcart&shoppingcart=206091607476087. 2. After purchase done my response is empty and getting 400 bad request. 3. I want to redirect automatically to my site.Listed under is my response code which i have use in calllbackurl. / Checkout Code / $cart = new GoogleCart?($this->merchant_id, $this->merchant_key, $this->server_type, $this->currency);

$mpd = new MerchantPrivateData?($customData); $cart->SetMerchantPrivateData?($mpd);

if(isset($customData['txnType'])) {
$transactionType = $customData['txnType'];
} else {
$transactionType = "Investment";
}

$item = new GoogleItem?($transactionType, $customData['cause'], $amount_of_shares, $price_per_share);

$item->SetURLDigitalContent(Router::url('/users/index/', true), "", ""); $cart->AddItem?($item);

$cart->CheckoutServer2Server?();

/ Checkout End/ / Response Code /

$post = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : file_get_contents("php://input");
$response = new GoogleResponse?($this->merchant_id, $this->merchant_key);
$response->SetLogFiles?(RESPONSE_HANDLER_ERROR_LOG_FILE, RESPONSE_HANDLER_LOG_FILE, L_ALL);
list($root, $data) = $response->GetParsedXML($post);
print_r($root);exit;
switch ($root) :

case "charge-amount-notification" : {
$response->SendAck?(); break;
}
case "merchant-calculation-callback" : {
break;
}
case "new-order-notification" : {
$this->GoogleUpdateOrders?($data[$root]);

break;
}

case "order-state-change-notification" : {
if ($data[$root]["previous-financial-order-state"]["VALUE"] == "CHARGING" && $data[$root]["new-financial-order-state"]["VALUE"] == "CHARGED") :

$this->updateFinancialOrderState($data[$root]);

elseif ($data[$root]["new-financial-order-state"]["VALUE"] == "CANCELLED") :
$this->cancelOrder($data[$root]);
endif;
$response->SendAck?();
break;

}

case "refund-amount-notification" : {
$response->SendAck?();
break;
}
case "risk-information-notification" : {
$response->SendAck?();
break;
}
default : {
$response->SendBadRequestStatus?("An error occurred.");
break;
}
endswitch;
$res = ob_get_contents();
$fh = fopen(WWW_ROOT . 'logs' . DS . 'google_log.txt', "w"); fwrite($fh, $res); fclose($fh);

/ Response Code End / Output:"An error occurred."

Operating System:Ubuntu,PHP:"5.2.4-2".

Please assist me on this ASAP.

Comment by go...@lifotechnologies.com, Nov 10, 2011

Hi We are using responsehandler.php for fetch the values from google thanks page. But got the error message "Invalid or not supported Message". Even we changed the setting in .htaccess and ..htpasswd file. google error file shows the same thing "Invalid or not supported Message"... Is any code modification required in responsehandler.php file or else? Please guide us. ......

We are using the Sample PHP code for integration of Google Checkout with the merchant site v1.3.1. The values send through cartdemo.php file to google checkout page.

Comment by ajarprod...@gmail.com, Nov 23, 2011

I'm having a lot of problems getting the sample code to work. This entire process is really frustrating compared to Paypal. The basic sample code should work without errors (and it seems to require a lot of debugging). The sandbox also leaves a lot to be desired. You should be able to generate payment events with the click of a button within the sandbox interface, and should not have to enter credit card data into the sandbox.

Comment by lee....@gmail.com, Dec 29, 2011

Does this code work when "Notification Serial Number" is checked for "Callback contents"?

I don't have https and I'd like to use the first of the three options, but the sdk doesn't seem to parse $root and $data at all. Activating the second option (Notification as XML) works fine in sandbox mode instead, but I suppose it won't in production since I don't have https.


Sign in to add a comment
Powered by Google Project Hosting