コード例 #1
0
ファイル: process_offer_ws.php プロジェクト: jawedkhan/rorca
function ws_request($url, $xml, $action)
{
    $header = array("Content-Type: text/xml; charset=utf-8");
    $header[] = 'SOAPAction: "' . $action . '"';
    $header[] = "Content-Length: " . strlen($xml);
    $header[] = 'Connection: close';
    $header[] = 'Cache-Control: no-cache';
    $header[] = 'User-agent: asiguram/tarifar 1.0';
    $header[] = 'Expect:';
    // Set the POST options.
    $session = curl_init();
    curl_setopt($session, CURLOPT_URL, $url);
    curl_setopt($session, CURLOPT_POST, true);
    curl_setopt($session, CURLOPT_HTTPHEADER, $header);
    curl_setopt($session, CURLOPT_POSTFIELDS, $xml);
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($session, CURLOPT_TIMEOUT, (int) 60);
    curl_setopt($session, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
    // Do the POST and then close the session
    $response = curl_exec($session);
    //echo $response;die();
    if (curl_errno($session)) {
        //echo curl_errno($session);die();
        return false;
    }
    $xml_parser = new gc_xmlparser($response);
    $data = $xml_parser->GetData();
    return $data;
}
コード例 #2
0
ファイル: googlerequest.php プロジェクト: annggeel/tienda
 /**
  * Submit a server-to-server request.
  * 
  * more info:
  * {@link http://code.google.com/apis/checkout/developer/index.html#alternate_technique}
  * 
  * @param string $xml_cart the cart's xml
  * @param bool $die whether to die() or not after performing the request,
  *                  defaults to true
  * 
  * @return array with the returned http status code (200 if OK) in index 0 
  *               and the redirect url returned by the server in index 1
  */
 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 {
         require_once dirname(__FILE__) . '/xml-processing/gc_xmlparser.php';
         $xml_parser = new gc_xmlparser($body);
         $root = $xml_parser->GetRoot();
         $data = $xml_parser->GetData();
         $redirect_url = $data[$root]['redirect-url']['VALUE'];
         $this->log->logRequest("Redirecting to: " . $redirect_url);
         if (strpos($redirect_url, "shoppingcartshoppingcart") != false) {
             $redirect_url = str_replace("shoppingcartshoppingcart", "shoppingcart&shoppingcart", $redirect_url);
         }
         header('Location: ' . $redirect_url);
         if ($die) {
             die($redirect_url);
         } else {
             return array(200, $redirect_url);
         }
     }
 }
コード例 #3
0
 /**
  * Get the Google Checkout button's html to be used with the html api.
  * 
  * {@link http://code.google.com/apis/checkout/developer/index.html#google_checkout_buttons}
  * 
  * @param string $size the size of the button, one of 'large', 'medium' or
  *                     'small'.
  *                     defaults to 'large'
  * @param bool $variant true for an enabled button, false for a 
  *                      disabled one. defaults to true. will be ignored if
  *                      SetButtonVariant() was used before.
  * @param string $loc the locale of the button's text, the only valid value
  *                    is 'en_US' (used as default)
  * @param bool $showtext whether to show Google Checkout text or not, 
  *                       defaults to true.
  * @param string $style the background style of the button, one of 'white'
  *                      or 'trans'. defaults to "trans"
  * 
  * @return string the button's html
  */
 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/gc_xmlparser.php';
         $xml_parser = new gc_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;
 }
コード例 #4
0
 /**
  * Submit a server-to-server request.
  * 
  * more info:
  * {@link http://code.google.com/apis/checkout/developer/index.html#alternate_technique}
  * 
  * @param string $xml_cart the cart's xml
  * @param bool $die whether to die() or not after performing the request,
  *                  defaults to true
  * 
  * @return array with the returned http status code (200 if OK) in index 0 
  *               and the redirect url returned by the server in index 1
  */
 public 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/gc_xmlparser.php';
         $xml_parser = new gc_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']);
         }
     }
 }