What's new? | Help | Directory | Sign in
Google
google-checkout-php-sample-code
PHP sample code for Google Checkout
  
  
  
  
    
Search
for
Updated Feb 15, 2007 by jacob13moon
Labels: Featured
Documentation  

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

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.

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 davidgutschick, Aug 06, 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 donmubiri, Aug 10, 2007

someone please explain what server 2 server is all about

Comment by frooglemale, 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 frooglemale, 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 frooglemale, 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 prashcom, 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 prashcom, 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 prashcom, 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 artistan, Oct 05, 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.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 sherifmayika, Nov 01, 2007

is there any documentation for novive php developers

sherif

Comment by thegempalace, 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 balasenthil, Dec 01, 2007

Hi

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

Comment by pragyabchar, Dec 06, 2007

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

Comment by shahdeveloper, Jan 06, 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 blogscheduler, 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 Izonomia, 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 Jorojam02, Apr 04, 2008

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

Comment by billskipton, Apr 08, 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 nicholasamps, Apr 09, 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 billskipton, Apr 09, 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 teddybugs, Apr 25, 2008

how to access the responsehandlerdemo.php

it keep display Invalid or not supported Message

Comment by nicholaswhitworth, May 01, 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 nicholasamps, May 02, 2008

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

Comment by gcttestbuyer, May 07, 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.


Sign in to add a comment