Store
Community Documentation

v3 Knowledgebase

Add Google Checkout as a Payment Gateway

This article will show you how to add Google Checkout as a Payment Gateway.
This is just to get you started. You may add complex functionality like processing refunds and cancellations as you wish.

This article builds on what was written in the article: How to add a Payment Gateway. Please go through it first.

Assumptions
  • You have created a test merchant account at https://sandbox.google.com/checkout/sell/ or a real merchant account at: http://checkout.google.com/sell/signup
  • HTTPS connection
  • In your merchant account settings, go to Integration settings and enter API Callback url as: https://yoursite.com/index.php?do= /api/gateway/callback/googlecheckout/ , Select the API version as 2.5 and Callback contents: as Notification as HTML (name/value pairs) and select the option under Notification Filtering




Next, download the file attached: gcheckout.zip

Rename the file "copy of googlecheckout.class.php" to "googlecheckout.class.php

Copy it to the folder: /include/library/phpfox/gateway/api/


(The following is an extract from the article: How to add a Payment Gateway)

Adding a Database Entry
Now that the PHP code is completed for your payment gateway you will have to add an entry in the database so it shows up in the AdminCP. The table we need to add information to is:

api_gateway


The fields that are required are:
gateway_id (Unique ID. This must be the same name as the PHP class you created earlier in the "/include/library/phpfox/gateway/api/" folder. )

title (Title of your payment gateway. Eg. Paypal, 2checkout etc...)


You can enter the database entry directly using the sql statement below:
insert into api_gateway (gateway_id,title) 

values ('googlecheckout','Make purchases by signing into your Google Account.');


Add Phrases
In the file googlecheckout.class.php, the function getEditForm() refers to four variables which you will require to create in the Admin panel.
Go to Admin Control Panel -> Extensions -> Add Phrase.

module.variable_name value

core.google_merchant_id = Google Checkout Merchant ID
core.your_google_merchant_id = merchant_id_descriptive text
core.google_merchant_key = Google Checkout Merchant Key
core.your_google_merchant_key = merchant_key_descriptive text

Add the four variables above.

Go to Admin Control Panel -> Settings -> Payment Gateways
You should see Google Checkout listed among the gateways.

Select Edit Gateway Settings. Enter the Merchant ID and Merchant Key. Save.

Basic Authentication
If PHP is running on your server as a module, then uncomment the lines 153 - 178 in the file googlecheckout.class.php and ignore the information below
The section of the file after the comment:
/* Verifies that the authentication sent by Google Checkout matches the
merchant id and key */

If the server you are running on is running PHP as a CGI then the variables $_SERVER[’PHP_AUTH_USER’] and $_SERVER[’PHP_AUTH_PW’] which google sends will not be created.

The work around is to use the .htaccess file and the htpasswd files attached.
The .htaccess file should be on the root (or add the contents to your already existing .htaccess file) and the htpasswd file to the place where you have specified in the .htaccess file.

Other
In this implementation, the Google Checkout HTML API was used, can modify to use XML API.

Please free to modify, comment and improve.