What is Payment Gateway integration?

A payment gateway can be defined as a third-party service, which is a combination of hardware and software that provides an interface to the bank credit card processing network. The credit card information is collected and is transferred over the Internet to the credit card processors in the encrypted format for transaction purposes. Some well-known payment gateways are AuthorizeNet, Google Checkout, USAePay, Verisign, and Paypal.

What is google checkout?

  • Using Google checkout buying from stores across the web becomes simple and also facilitates you to keep track of all the orders.
  • The Google Checkout’s fraud protection policy protects you against all unauthorized purchases made via Google Checkout. Another advantage is that the Google Checkout does not share the history of the purchasers with other sellers.
  • With Google Checkout, your email is well protected and is kept confidential. Tracking down your purchase history list is also simple.

Methods to Integrate with Google checkout:

Google checkout Provides three different types of integration methods
Buy Now Buttons (Provided by Google Checkout).
Valid eCommerce Partners.
Google Checkout API (Code Integration with Google Checkout).

1) Buy Now Buttons

If you do not require the shopping cart functionality, you can simply integrate with Google Checkout using the Google Checkout Buy Now buttons. You can have these buttons be displayed next to the products you are selling by just adding the Google checkout’s HTML code to your website. Visitors/Buyers who click this button will be automatically directed to the secure Google Checkout page where they can complete their purchase.

Integration requirements: You have a working knowledge of your website’s HTML.

2) eCommerce Partners

If your shopping cart application is being provided by one of the Google checkout’s partners, you can simply integrate your shopping cart and order processing functionalities with Google Checkout.

Integration requirements: You have a shopping cart provided by a valid eCommerce partner.

3) Google Checkout API

Integrating our website which has a shopping cart and order processing system via the Google Checkout API (Sample Codes) is a simple process.
The Google Checkout API is available in the following Codes:

  • ASP (Active Server Pages)
  • .Net (Visual Studio .Net)
  • PHP (Hypertext Preprocessor)
  • Java 1.5
  • Java 1.4

Integrating with Google checkout by using the Google Checkout API with PHP can be seen in the Sample Code. You can download the Sample code provided by the Google Checkout API (PHP) from here ยป PHP Sample Code.

**Before going to use the Sample code provided by Google checkout you need to check the following configuration settings are available in your PHP server.

  • PHP Version- PHP v4.3.0 or later (But Not greater or equal to PHP 5.0, because Current Google checkout API codes support only the Lower versions of PHP 5.0).
  • CURL – libcurl v7.9.0 or later libcurl is an implementation of CURL (PHP supports libcurl, that allows you to connect and communicate to many different types of servers by using different protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols), which allows you to send XML over HTTPS using server-to-server HTTP POST requests.
  • libxml-2.4.14 or later. libxml installs a DOM XML library (This Dom XML library is used to parse and construct the XML Messages).

Some Important PHP Library Files provided by the Google Checkout

  • GlobalAPIFunctions.php – This library contains functions that are used to communicate with multiple Google Checkout APIs.
    Some Important Functions are

    1. GetMerchantID – The GetMerchantID function returns your Google Checkout merchant ID ( You can get this Merchant ID by Registering as a Merchant with the Google Checkout).
    2. GetMerchantKey – The GetMerchantKey function returns your Google Checkout merchant key ( You can get this Merchant key by Registering as a Merchant with the Google Checkout)
    3. CalcHmacSha1 -The CalcHmacSha1 function uses a checkout shopping cart XML file, which contains information about an order, and your merchant key to compute a cryptographically secure HMAC-SHA1 value
    4. SendRequest – The SendRequest function verifies that you have provided values for all of the parameters needed to send a Google Checkout or Order Processing API request.
  • ResponseHandlerAPIFunctions.php – This library contains functions that handle synchronous responses that Google Checkout sends in response to your API requests. Some Important Functions are
    1. ProcessXmlData – The ProcessXmlData function creates a DOM object representation of the XML document received from Google Checkout.
    2. ProcessRequestReceivedResponse – The ProcessRequestReceivedResponse function receives a synchronous Google Checkout response to an API request originating from your site.
    3. ProcessErrorResponse – The ProcessErrorResponse function receives a synchronous Google Checkout response to an API request originating from your site.
  • CheckoutAPIFunctions.php – This library contains functions for systematically building XML documents that can be included in Google Checkout Checkout API requests Some Important Functions are
    1. CreateItem – The CreateItem function constructs the XML for a single <item> in a shopping cart(Here we have to list each product as an item).
    2. CreateShoppingCart – The CreateShoppingCart function constructs the XML for the <shopping-cart> element in a Checkout API request.
    3. CreateCheckoutShoppingCart – The CreateCheckoutShoppingCart function returns the <checkout-shopping-cart> XML structure, which contains all of the items and checkout-related information for an order.

The Screen Shots for the Google Checkout Integration For an Online Event Registration

A Sample Shopping Cart with Google Checkout Button

Your Sample Cart Page

Return top

After Pressing the Google Checkout Button, You will get the Following Sign in Page

Sign in to Google Checkout

This below page you can view two different items
1) The Event name (The event which you need to book online)
2) The Service Charge (The Service Charge Amount for the Particular Event Ticket)
In this Page, if you are an already existing user, You will give your Email address as the username and your password to login into the Review & Place the Order page.
Else you will have a provision to enter your Credit card details and need to create an account with the Google Checkout.

Return top

After Successful Register/Sign up You will get the following page

Review & Place Your Order

In This Review & Place order page, you will confirm your Order details and Place your order. After the Successful Placement of the order, A copy of your order will be emailed to the Merchant and also a copy to the person who places the order.
An Added feature available in the Google Checkout is a copy that will be stored in your Purchase history list.

Return top

Thanks, Page

After Pressing the Place order button you will get the following page

Return top

Vital Information needed to Configure the Google Checkout **

  1. PHP Version- PHP v4.3.0 or later
  2. CURL – libcurl v7.9.0 or later
  3. libxml-2.4.14 or later.
  4. SSL Certificate** – If you are a merchant, and needed to calculate the Order Status after the Order Placement means you need to Install SSL Certificate (Secure Socket Layer, This is a certificate which is installed on a secure server. It is used to identify the merchant using it and to encrypt the credit card) in your server and place a php file to Capture the Response from the Google Checkout.


Sample Merchant Calculation Coding to Capture the Response Acknowledgement from the Google Checkout for the Every order.

// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
$xml_response = $HTTP_RAW_POST_DATA;
Get rid of PHP’s magical escaping of quotes
if (get_magic_quotes_gpc()) {
$xml_response = stripslashes($xml_response);
// Capture the Return Response XML from the Google Checkout.
function fnWriteXml($string){
if(file_exists($file)) {
$fileid = fopen($file,”a”);
$strmsg = “”;
$strmsg.= “***************************************************\r\n”;
$fileid = fopen($file,”a”);
$strmsg = $string;
By Downloading the file ssl_return.txt you will get the Response XML From the Google Checkout. Parse the Response XML, according to your needs and manipulate the Merchant Calculation Codings.

Functional Definitions :

stripslashes – Returns a string with backslashes stripped off.(\’ becomes ‘ and so on.) Double backslashes are made into a single backslash.

get_magic_quotes_gpc() – Gets the current active configuration setting of magic quotes.

fopen – This keyword is used to open the specified file in the Specified server path
If the open fails, the function returns FALSE.
for Example : fopen(“sample.txt”,”a”);
Here the First argument is the File name and the second one is the File open mode type. Some of the File open mode types are(‘r’-Read-only, ‘r+’- Reading & Writing, ‘w’- Writing only, ‘w+’ – Reading & writing,’a’- Append writing only,’a+’- Reading & Append Writing only)

file_exists– Returns TRUE if the file specified by filename exists; else it returns FALSE.

* This function will not work on remote files;

fwrite – it writes the contents of string to the file stream pointed to by fp. If the length argument is given, writing will stop after length bytes have been written or the end of the string is reached, whichever comes first.

fclose – The file pointed to by fp is closed. Returns TRUE on success, FALSE on failure.



Like to get support from an Expert PHP developer? Like to outsource your PHP app development? Reach us out for a quick and free consulting.

How to create Dynamic PDF with PHP? Learn here.