public function start_ipn($data, $config)
    {
        require_once 'assets/google-checkout/library/googlecart.php';
        require_once 'assets/google-checkout/library/googleitem.php';
        require_once 'assets/google-checkout/library/googleshipping.php';
        require_once 'assets/google-checkout/library/googletax.php';
        $merchant_id = $config['merchant_id'];
        // Your Merchant ID
        $merchant_key = $config['merchant_key'];
        // Your Merchant Key
        $server_type = $config['sandbox'];
        $currency = "USD";
        $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
        $cart->SetMerchantPrivateData(new MerchantPrivateData(array("transaction_id" => $data['transaction_id'])));
        $i = 1;
        foreach ($data["cart"]["items"] as $items) {
            ${'item_' . $i} = new GoogleItem($items['title'], "", $items['quantity'], $this->_currency_round($items["price"]));
            ${'item_' . $i}->SetMerchantItemId($items["product_id"]);
            $cart->AddItem(${'item_' . $i});
            $i++;
        }
        // Applying a discount
        if ($data['cart_discount'] != 0) {
            ${'item_' . $i} = new GoogleItem("Discount Applied", "", 1, "-" . $this->_currency_round($data['cart_discount']));
            $cart->AddItem(${'item_' . $i});
        }
        // Calculating the Tax by taking the subtotal, subtracting the discount and
        // dividing by the pre-calculated rate.
        // -- Then formatting the number by 2 decimal places
        if ($data['cart_tax'] == 0) {
            $taxrate = 0;
        } else {
            $taxrate = number_format($data['cart_subtotal'] - $data['cart_discount'] / $data['cart_tax'], 2);
        }
        $tax_rule = new GoogleDefaultTaxRule($taxrate);
        $tax_rule->SetWorldArea(true);
        $cart->AddDefaultTaxRules($tax_rule);
        $ship_1 = new GoogleFlatRateShipping("Shipping", $data['cart_shipping']);
        $cart->AddShipping($ship_1);
        // Specify <edit-cart-url>
        $cart->SetEditCartUrl($data['return']);
        // Specify "Return to xyz" link
        $cart->SetContinueShoppingUrl($data['cancel_return']);
        // Define rounding policy
        $cart->AddRoundingPolicy("CEILING", "TOTAL");
        echo '	<html>
   	        			<head>
   	        				<title>Google Checkout</title>
   	        			</head>
   	        			<body onLoad="document.forms[\'gateway_form\'].submit();">
							<form method="post" name="gateway_form" action="' . $cart->checkout_url . '">
			    				<input type="hidden" name="cart" value="' . base64_encode($cart->GetXML()) . '"/>
								<input type="hidden" name="signature" value="' . base64_encode($cart->CalcHmacSha1($cart->GetXML())) . '" />
								<p style="text-align:center;">
									Your order is being processed... will be redirected to the payment website.
								 	<br />
								 	<br />
								 	If you are not automatically redirected to Google Checkout within 5 seconds...<br /><br />
									<input type="submit" value="Click Here">
								</p>
							</form>
						</body>
					</html>';
    }
 /**
  * Sets appropriate parameters for checking out to google
  *
  * @param array $params name value pair of contribution datat
  *
  * @param $component
  * @throws Exception
  * @return void
  */
 function doTransferCheckout(&$params, $component)
 {
     $component = strtolower($component);
     $url = rtrim($this->_paymentProcessor['url_site'], '/') . '/cws/v2/Merchant/' . $this->_paymentProcessor['user_name'] . '/checkout';
     //Create a new shopping cart object
     // Merchant ID
     $merchant_id = $this->_paymentProcessor['user_name'];
     // Merchant Key
     $merchant_key = $this->_paymentProcessor['password'];
     $server_type = $this->_mode == 'test' ? 'sandbox' : '';
     $cart = new GoogleCart($merchant_id, $merchant_key, $server_type);
     $item1 = new GoogleItem($params['item_name'], '', 1, $params['amount'], $params['currencyID']);
     $cart->AddItem($item1);
     if ($component == "event") {
         $privateData = "contactID={$params['contactID']},contributionID={$params['contributionID']},contributionTypeID={$params['contributionTypeID']},eventID={$params['eventID']},participantID={$params['participantID']},invoiceID={$params['invoiceID']}";
     } elseif ($component == "contribute") {
         $privateData = "contactID={$params['contactID']},contributionID={$params['contributionID']},contributionTypeID={$params['contributionTypeID']},invoiceID={$params['invoiceID']}";
         $membershipID = CRM_Utils_Array::value('membershipID', $params);
         if ($membershipID) {
             $privateData .= ",membershipID={$membershipID}";
         }
         $relatedContactID = CRM_Utils_Array::value('related_contact', $params);
         if ($relatedContactID) {
             $privateData .= ",relatedContactID={$relatedContactID}";
             $onBehalfDupeAlert = CRM_Utils_Array::value('onbehalf_dupe_alert', $params);
             if ($onBehalfDupeAlert) {
                 $privateData .= ",onBehalfDupeAlert={$onBehalfDupeAlert}";
             }
         }
     }
     // Allow further manipulation of the arguments via custom hooks ..
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $privateData);
     $cart->SetMerchantPrivateData($privateData);
     if ($component == "event") {
         $returnURL = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$params['qfKey']}", TRUE, NULL, FALSE);
     } elseif ($component == "contribute") {
         $returnURL = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$params['qfKey']}", TRUE, NULL, FALSE);
     }
     $cart->SetContinueShoppingUrl($returnURL);
     $cartVal = base64_encode($cart->GetXML());
     $signatureVal = base64_encode($cart->CalcHmacSha1($cart->GetXML()));
     $googleParams = array('cart' => $cartVal, 'signature' => $signatureVal);
     require_once 'HTTP/Request.php';
     $params = array('method' => HTTP_REQUEST_METHOD_POST, 'allowRedirects' => FALSE);
     $request = new HTTP_Request($url, $params);
     foreach ($googleParams as $key => $value) {
         $request->addPostData($key, $value);
     }
     $result = $request->sendRequest();
     if (PEAR::isError($result)) {
         CRM_Core_Error::fatal($result->getMessage());
     }
     if ($request->getResponseCode() != 302) {
         CRM_Core_Error::fatal(ts('Invalid response code received from Google Checkout: %1', array(1 => $request->getResponseCode())));
     }
     CRM_Utils_System::redirect($request->getResponseHeader('location'));
     exit;
 }