<?php

require_once 'classes/PluginCallback.php';
require_once 'classes/class.gateway.plugin.php';
require_once 'plugins/gateways/googlecheckout/googlefunctions.php';

class PluginGooglecheckoutCallback extends PluginCallback
{
    
    function processCallback()
    {
        if(isset($_COOKIE['returnToSignup'])){
    		if($_COOKIE['returnToSignup'] == 1){
    			NE_Lib::redirectPage($this->settings->get('ClientExec URL').'/signup.php?step=6&pass=1');
    		}
    		if($_COOKIE['returnToSignup'] == 0){
    			NE_Lib::redirectPage($this->settings->get('ClientExec URL').'/index.php');
    		}
    		exit;
        }
        
        $this->logger->log(5,'Google Checkout callback invoked');
        
        // Retrieve the XML sent in the HTTP POST request to the ResponseHandler
        $xml_response = $GLOBALS['HTTP_RAW_POST_DATA'];
        
        // Get rid of PHP's magical escaping of quotes 
        if (get_magic_quotes_gpc()) {
            $xml_response = stripslashes($xml_response);
        }
        
        // Log the XML received in the HTTP POST request
        $this->logger->log(5, "XML response: ".print_r($xml_response, true));
        
        // EWW
        $GLOBALS['logger'] =& $this->logger;
        $GLOBALS['db'] =& $this->db;
        $GLOBALS['user'] =& $this->user;
        $GLOBALS['customer'] =& $this->customer;
               
        ProcessXmlData($xml_response);
    }
    
}

?>
