function SendServer2ServerCart($xml_cart, $die = true) { list($status, $body) = $this->SendReq($this->merchant_checkout, $this->GetAuthenticationHeaders(), $xml_cart); if ($status != 200) { return array($status, $body); } else { ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '.'); require_once 'xml-processing/xmlparser.php'; $xml_parser = new XmlParser($body); $root = $xml_parser->GetRoot(); $data = $xml_parser->GetData(); $this->log->logRequest("Redirecting to: " . $data[$root]['redirect-url']['VALUE']); header('Location: ' . $data[$root]['redirect-url']['VALUE']); if ($die) { die($data[$root]['redirect-url']['VALUE']); } else { return array(200, $data[$root]['redirect-url']['VALUE']); } } }
/** * This method is handles the response that will be invoked (from extern/googleNotify) every time * a notification or request is sent by the Google Server. * */ static function main($xml_response) { require_once 'Google/library/googleresponse.php'; require_once 'Google/library/googlemerchantcalculations.php'; require_once 'Google/library/googleresult.php'; require_once 'Google/library/xml-processing/xmlparser.php'; $config = CRM_Core_Config::singleton(); // Retrieve the XML sent in the HTTP POST request to the ResponseHandler if (get_magic_quotes_gpc()) { $xml_response = stripslashes($xml_response); } require_once 'CRM/Utils/System.php'; $headers = CRM_Utils_System::getAllHeaders(); if (GOOGLE_DEBUG_PP) { CRM_Core_Error::debug_var('RESPONSE', $xml_response, TRUE, TRUE, 'Google'); } // Retrieve the root and data from the xml response $xmlParser = new XmlParser($xml_response); $root = $xmlParser->GetRoot(); $data = $xmlParser->GetData(); $orderNo = $data[$root]['google-order-number']['VALUE']; // lets retrieve the private-data $privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE']; $privateData = $privateData ? self::stringToArray($privateData) : ''; list($mode, $module, $paymentProcessorID) = self::getContext($xml_response, $privateData, $orderNo, $root); $mode = $mode ? 'test' : 'live'; require_once 'CRM/Financial/BAO/PaymentProcessor.php'; $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode); $ipn =& self::singleton($mode, $module, $paymentProcessor); // Create new response object $merchant_id = $paymentProcessor['user_name']; $merchant_key = $paymentProcessor['password']; $server_type = $mode == 'test' ? "sandbox" : ''; $response = new GoogleResponse($merchant_id, $merchant_key, $xml_response, $server_type); if (GOOGLE_DEBUG_PP) { CRM_Core_Error::debug_var('RESPONSE-ROOT', $response->root, TRUE, TRUE, 'Google'); } //Check status and take appropriate action $status = $response->HttpAuthentication($headers); switch ($root) { case "request-received": case "error": case "diagnosis": case "checkout-redirect": case "merchant-calculation-callback": break; case "new-order-notification": $response->SendAck(); $ipn->newOrderNotify($data[$root], $privateData, $module); break; case "order-state-change-notification": $response->SendAck(); $new_financial_state = $data[$root]['new-financial-order-state']['VALUE']; $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE']; switch ($new_financial_state) { case 'CHARGEABLE': $amount = $ipn->getAmount($orderNo); if ($amount) { $response->SendChargeOrder($data[$root]['google-order-number']['VALUE'], $amount, $message_log); $response->SendProcessOrder($data[$root]['google-order-number']['VALUE'], $message_log); } break; case 'CHARGED': case 'PAYMENT_DECLINED': case 'CANCELLED': $ipn->orderStateChange($new_financial_state, $data[$root], $module); break; case 'REVIEWING': case 'CHARGING': case 'CANCELLED_BY_GOOGLE': break; default: break; } case "charge-amount-notification": case "chargeback-amount-notification": case "refund-amount-notification": case "risk-information-notification": $response->SendAck(); break; default: break; } }
$current = "http://devfiles.quizsnack.net.s3.amazonaws.com/templates/xml/" . $arr[0]; if (!isset($filters['categories'])) { $filters['categories'] = ''; } if (!isset($filters['subcategories'])) { $filters['subcategories'] = ''; } if ($handle = @fopen($current, "rb")) { fclose($handle); $use_include_path = 0; $dat = array(); $dat = gzfile($current, $use_include_path); $datu = implode($dat); $xml = $datu; $xmlParser = new XmlParser($xml); $data = $xmlParser->GetData(); if (isset($data['configs'])) { $categories = array(); $subcategories = array(); $parameters_in_selection = array(); $count_params = 0; foreach ($data['configs']['categories']['category'] as $cat => $cat_item) { ///echo"[ name : ".$cat_item['name']."]<br>"; $categories[] = $cat_item['name']; $query_suppress = 1; if ($filters['categories'] == $cat_item['name'] || $filters['categories'] == '') { // deg($filters['categories']); // deg($cat_item['name']); foreach ($cat_item['params'] as $subcat => $subcat_item) { if (is_array($subcat_item)) { if (isset($subcat_item['subcatLabel'])) {
/** * @param $xmlData * * @return array */ static function getArrayFromXML($xmlData) { require_once 'Google/library/xml-processing/xmlparser.php'; $xmlParser = new XmlParser($xmlData); $root = $xmlParser->GetRoot(); $data = $xmlParser->GetData(); return array($root, $data); }
function CheckoutHTMLButtonCode($size = "large", $variant = true, $loc = "en_US", $showtext = true, $style = "trans") { switch (strtolower($size)) { case "medium": $width = "168"; $height = "44"; break; case "small": $width = "160"; $height = "43"; break; case "large": default: $width = "180"; $height = "46"; break; } if ($this->variant == false) { switch ($variant) { case false: $this->variant = "disabled"; break; case true: default: $this->variant = "text"; break; } } $data = "<div style=\"width: " . $width . "px\">"; if ($this->variant == "text") { $data .= "<div align=\"center\"><form method=\"POST\" action=\"" . $this->checkoutForm_url . "\"" . ($this->googleAnalytics_id ? " onsubmit=\"setUrchinInputCode();\"" : "") . ">"; $request = $this->GetXML(); require_once 'xml-processing/xmlparser.php'; $xml_parser = new XmlParser($request); $root = $xml_parser->GetRoot(); $XMLdata = $xml_parser->GetData(); $this->xml2html($XMLdata[$root], '', $data); $data .= "<input type=\"image\" name=\"Checkout\" alt=\"Checkout\" " . "src=\"" . $this->server_url . "buttons/checkout.gif?merchant_id=" . $this->merchant_id . "&w=" . $width . "&h=" . $height . "&style=" . $style . "&variant=" . $this->variant . "&loc=" . $loc . "\" \n height=\"" . $height . "\" width=\"" . $width . "\" />"; if ($this->googleAnalytics_id) { $data .= "<input type=\"hidden\" name=\"analyticsdata\" value=\"\">"; } $data .= "</form></div>"; if ($this->googleAnalytics_id) { $data .= "<!-- Start Google analytics -->\n <script src=\"https://ssl.google-analytics.com/urchin.js\" type=\"" . "text/javascript\">\n </script>\n <script type=\"text/javascript\">\n _uacct = \"" . $this->googleAnalytics_id . "\";\n urchinTracker();\n </script>\n <script src=\"https://checkout.google.com/files/digital/urchin_po" . "st.js\" type=\"text/javascript\"></script> \n <!-- End Google analytics -->"; } } else { $data .= "<div align=\"center\"><img alt=\"Checkout\" src=\"" . "" . $this->server_url . "buttons/checkout.gif?merchant_id=" . "" . $this->merchant_id . "&w=" . $width . "&h=" . $height . "&style=" . $style . "&variant=" . $this->variant . "&loc=" . $loc . "\" height=\"" . $height . "\"" . " width=\"" . $width . "\" /></div>"; } if ($showtext) { $data .= "<div align=\"center\"><a href=\"javascript:void(window.ope" . "n('http://checkout.google.com/seller/what_is_google_checkout.html'" . ",'whatischeckout','scrollbars=0,resizable=1,directories=0,height=2" . "50,width=400'));\" onmouseover=\"return window.status = 'What is G" . "oogle Checkout?'\" onmouseout=\"return window.status = ''\"><font " . "size=\"-2\">What is Google Checkout?</font></a></div>"; } $data .= "</div>"; return $data; }
/** * static method * * @param array $ids The ids of the items to retrieve. * * @return array An array with id => GoogleBaseItem. */ function getGbaseItemsFromDb($ids) { global $db; if (!defined('TABLE_GOOGLEBASE')) { require_once dirname(realpath(__FILE__)) . '/../../languages/english/extra_definitions/googlebase.php'; } $query = "select gb.products_id as id, gb.googlebase_item_xml as item_xml\n from " . TABLE_GOOGLEBASE . " gb\n where gb.products_id in (" . implode(', ', $ids) . ")\n group by gb.products_id"; $result = $db->Execute($query); $items = array(); while (!$result->EOF) { $xmlp = new XmlParser(stripslashes($result->fields['item_xml'])); $data = $xmlp->GetData(); $item = new GoogleBaseItem(); $item->takeFromArray($data['entry']); $items[(int) $result->fields['id']] = $item; $result->MoveNext(); } return $items; }
/** * @return array An array representation of the xml data as * array('xmlroot' => the root element name of the data, * 'xmldata' => the parsed xml), as returned by {@link XmlParser} */ function getParsedXmlResponseBody() { $xmlp = new XmlParser($this->_body); return array('xmlroot' => $xmlp->GetRoot(), 'xmldata' => $xmlp->GetData()); }