Source for file gCart.php

Documentation is available at gCart.php

  1. <?php
  2. /**
  3. * ========================================================
  4. * phpGCheckout, Open Source PHP G Checkout Library
  5. * http://www.phpgcheckout.com
  6. * ========================================================
  7. *
  8. * Copyright (c) 2006 Expert Database Solutions, LLC
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation the
  13. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. * copies of the Software, and to permit persons to whom the Software is
  15. * furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in all
  18. * copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  21. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  22. * PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
  25. * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. *
  27. */
  28. /**
  29. * Google GCheckout / Checkout Shopping cart object
  30. *
  31. * @author Ron Howard
  32. * @copyright Expert Database Solutions, LLC 2006
  33. *
  34. */
  35. class gCart{
  36. var $_php_version;
  37. var $_mercant_id;
  38. var $_mercant_key;
  39. var $_arr_shopping_cart;
  40. var $_serializer_options;
  41. var $_state_serializer_options;
  42. var $_zip_serializer_options;
  43. var $_state_area_serializer_options;
  44. var $_alt_tax_table_serializer_options;
  45. var $_remove_tags;
  46. var $_tax_tables;
  47. var $_shipping;
  48. var $_items;
  49. var $_merchant_private_data;
  50. var $_merchant_calculations;
  51. var $_platform_id;
  52. /**
  53. * phpGCheckout Constructor
  54. *
  55. * @param string mercant_id
  56. * @param string $mercant_key
  57. */
  58. function gCart($mercant_id, $mercant_key, $cart_expires = '', $merchant_private_data= "") {
  59. /**
  60. * Set your Google GCheckout Mercant information.
  61. */
  62. $this->_mercant_id = $mercant_id;
  63. $this->_mercant_key = $mercant_key;
  64. /**
  65. * Set Current PHP Versionin information.
  66. */
  67. $this->_php_version = explode("-", phpversion());
  68. $this->_php_version = explode(".", $this->_php_version[0]);
  69. /**
  70. * Initialize Shopping Cart
  71. */
  72. $this->_setShoppingCart();
  73. /**
  74. * Set Serializer Options
  75. */
  76. $this->_setSerializerOptions();
  77. /**
  78. * Check Cart Expires Date
  79. */
  80. if(!empty($cart_expires)) {
  81. $this->setCartExpirationDate($cart_expires);
  82. }
  83. /**
  84. * Merchant Private Data
  85. */
  86. $this->_merchant_private_data = $merchant_private_data;
  87. /**
  88. * set remove tags
  89. */
  90. $this->_remove_tags = array("<REMOVE>", "</REMOVE>");
  91. /**
  92. * Add Platform ID
  93. */
  94. if(defined('PLATFORM_ID'))
  95. $this->_platform_id = PLATFORM_ID;
  96. }
  97. //////////////////////////////////////////////
  98. // PUBLIC METHODS
  99. //////////////////////////////////////////////
  100. /**
  101. * Returns the XML GCheckout Shopping Cart
  102. *
  103. * @return XML GCheckout Checkout Shopping Cart
  104. * @access public
  105. */
  106. function getCart() {
  107. /**
  108. * Add Tax Tables to the cart
  109. */
  110. if(!empty($this->_tax_tables))
  111. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['tax-tables'] = $this->_tax_tables;
  112. /**
  113. * Add Shipping Methods to the cart
  114. */
  115. if(!empty($this->_shipping))
  116. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods'] = $this->_shipping;
  117. /**
  118. * Add Items to the cart
  119. */
  120. if(!empty($this->_items))
  121. $this->_arr_shopping_cart['shopping-cart']['items'] = $this->_items;
  122. /**
  123. * Add Merchant Private Data to cart
  124. */
  125. if(!empty($this->_merchant_private_data))
  126. $this->_arr_shopping_cart['shopping-cart']['merchant-private-data'] = $this->_merchant_private_data;
  127. /**
  128. * Add Merchant Calculations to cart
  129. */
  130. if(!empty($this->_merchant_calculations))
  131. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['merchant-calculations'] = $this->_merchant_calculations;
  132. /**
  133. * Add Platform ID
  134. */
  135. if(!empty($this->_platform_id))
  136. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['platform-id'] = $this->_platform_id;
  137. /**
  138. * Get New XML Serializer
  139. */
  140. $serializer = new XML_Serializer($this->_serializer_options);
  141. $rslt = $serializer->serialize($this->_arr_shopping_cart);
  142. // Display the XML document;
  143. return $serializer->getSerializedData();
  144. }
  145. /**
  146. * Returns the XML Shopping Cart Signature
  147. *
  148. * @param string $xml_cart
  149. * @return string
  150. * @access public
  151. */
  152. function getSignature($xml_cart) {
  153. return $this->_getHmacSha1($xml_cart, $this->_mercant_key);
  154. }
  155. /**
  156. * Adds an Item to the GCheckout Cart
  157. *
  158. * @param unknown_type $item_name
  159. * @param unknown_type $item_description
  160. * @param unknown_type $quantity
  161. * @param unknown_type $unit_price
  162. * @param unknown_type $tt_selector
  163. * @param unknown_type $private_item_data
  164. * @access public
  165. */
  166. function addItem($item_name, $item_description, $quantity = 1, $unit_price = 0,
  167. $tt_selector="", $private_item_data="") {
  168.  
  169. /**
  170. * Check if there are already items in the cart
  171. */
  172. if(empty($this->_arr_shopping_cart['shopping-cart']['items'])) {
  173. $this->_arr_shopping_cart['shopping-cart']['items'] = array();
  174. }
  175. /**
  176. * Strip HTML entities
  177. */
  178. $item_name = htmlentities($item_name);
  179. $item_description = htmlentities($item_description);
  180. /**
  181. * Build New Item Array
  182. */
  183. $arr_item = array(
  184. 'item-name' => $item_name,
  185. 'item-description' => $item_description,
  186. 'unit-price' => array(
  187. '_attributes' => array('currency' => $GLOBALS['GCheckout_currency']),
  188. '_content' => $unit_price
  189. ),
  190. 'quantity' => $quantity
  191. );
  192. if(!empty($private_item_data)) {
  193. $arr_item['merchant-privat-item-data'] = $private_item_data;
  194.  
  195. }
  196. if(!empty($tt_selector)) {
  197. $arr_item['tax-table-selector'] = $tt_selector;
  198. }
  199. /**
  200. * Push the Item into the cart
  201. */
  202. array_push($this->_arr_shopping_cart['shopping-cart']['items'], $arr_item);
  203. }
  204. /**
  205. * Add an array of gItem objects to your cart
  206. *
  207. *
  208. * @param array $arr_items
  209. * @access public
  210. */
  211. function addItems($arr_items) {
  212. $str_xml = "";
  213. foreach ($arr_items as $item) {
  214. $str_xml .= $item->getXML();
  215. }
  216. $this->_items = $str_xml;
  217. }
  218. /**
  219. * Sets the expiration of the shopping cart. Note: google specified UTC time.
  220. *
  221. * @param UTC Timestamp $expire_date
  222. * @access public
  223. */
  224. function setCartExpirationDate($expire_date) {
  225. $this->_arr_shopping_cart['shopping-cart']['cart-expiration'] = array('good-until-date' => $expire_date);
  226. }
  227. /**
  228. * Sets a mercant flat rate shipping charge
  229. *
  230. * DEPRICATED: Use gShipping Object
  231. *
  232. * @param string $name
  233. * @param decimal $price
  234. * @access public
  235. */
  236. function setFlatRateShipping($name, $price, $allowed_restrictions = "", $excluded_restrictions = "") {
  237. /**
  238. * Get shipping object
  239. */
  240. $arr_flat_rate_shipping_obj = $this->_getShippingArray('flat-rate-shipping', $name, $price, $allowed_restrictions, $excluded_restrictions);
  241. /**
  242. * Append to shipping method array
  243. */
  244. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods']['flat-rate-shipping'] = $arr_flat_rate_shipping_obj;
  245. }
  246.  
  247. /**
  248. * Set a Pickup Shipping Option
  249. *
  250. * DEPRICATED: Use gShipping object
  251. *
  252. * @param string $name
  253. * @param decimal $price
  254. * @access public
  255. */
  256. function setPickup($name, $price) {
  257. /**
  258. * Get shipping object
  259. */
  260. $arr_pickup = $this->_getShippingArray('pickup', $name, $price);
  261. /**
  262. * Append to shipping method array
  263. */
  264. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods']['pickup'] = $arr_pickup;
  265. }
  266. /**
  267. * Set merchant calculated shipping option.
  268. *
  269. * DEPRICATED: Use gShipping object
  270. * Note: this method isn't fully implemented yet. Merchant calculations require a callback uri.
  271. *
  272. * @param string $name
  273. * @param decimal $price
  274. * @param unknown_type $shipping_restrictions
  275. * @access public
  276. */
  277. function setMercantCalculatedShipping($name, $price,$allowed_restrictions = "", $excluded_restrictions = "") {
  278. /**
  279. * Get shipping object
  280. */
  281. $arr_merchant_calculated_shipping = $this->_getShippingArray('merchant-calculated-shipping', $name, $price, $allowed_restrictions, $excluded_restrictions);
  282. /**
  283. * Append to shipping method array
  284. */
  285. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods']['merchant-calculated-shipping'] = $arr_merchant_calculated_shipping;
  286. }
  287. /**
  288. * returns shipping-restriction object
  289. *
  290. * @param unknown_type $country_area
  291. * @param unknown_type $arr_states
  292. * @param unknown_type $arr_zips
  293. * @return unknown
  294. * @access public
  295. */
  296. function getAllowedAreas($country_area, $arr_states, $arr_zips) {
  297. return $this->_getAllowedAreas($country_area, $arr_states, $arr_zips);
  298. }
  299. /**
  300. * returns shipping restriction object
  301. *
  302. * @param unknown_type $country_area
  303. * @param unknown_type $arr_states
  304. * @param unknown_type $arr_zips
  305. * @return unknown
  306. * @access public
  307. *
  308. */
  309. function getExcludedAreas($country_area, $arr_states, $arr_zips) {
  310. return $this->_getAllowedAreas($country_area, $arr_states, $arr_zips, $type = "excluded");
  311. }
  312.  
  313. /**
  314. * Set's the Merchante Checkout Flow Support
  315. *
  316. * @param unknown_type $edit_cart_url
  317. * @param unknown_type $continue_shopping_url
  318. * @param unknown_type $request_buyer_phone_number
  319. * @param unknown_type $platform_id
  320. */
  321. function setMerchantCheckoutFlowSupport($edit_cart_url ="", $continue_shopping_url = "", $request_buyer_phone_number = false, $platform_id = null) {
  322. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['edit-cart-url'] = $edit_cart_url;
  323. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['continue-shopping-url'] = $continue_shopping_url;
  324. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['request-buyer-phone-number'] = ($request_buyer_phone_number == true ? 'true' : 'false' );
  325. if(!empty($platform_id))
  326. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['platform-id'] = $platform_id;
  327. }
  328. /**
  329. * Add Alternate Tax Tables to the cart
  330. *
  331. * @param array $arr_tax_tables
  332. * @access public
  333. */
  334. function setAlternateTaxTables($arr_tax_tables) {
  335. $this->_setTaxTables($arr_tax_tables);
  336. }
  337. /**
  338. * Add a Default Tax Table to the cart
  339. *
  340. * @param gTaxTable $default_tax_table
  341. * @access public
  342. */
  343. function setDefaultTaxTable($default_tax_table){
  344. $this->_setTaxTables(array($default_tax_table), 'default');
  345. }
  346. /**
  347. * Add an array of gShipping objects to the cart
  348. *
  349. * @param array $arr_shipping
  350. * @access public
  351. */
  352. function setShipping($arr_shipping){
  353. $this->_setShipping($arr_shipping);
  354. }
  355. /**
  356. * Add a Merchant Calculations object to the array.
  357. *
  358. * @param gMerchantCalculations $MerchantCalculations
  359. * @access public
  360. */
  361. function setMerchantCalculations($MerchantCalculations) {
  362. if(!empty($MerchantCalculations))
  363. $this->_merchant_calculations = $MerchantCalculations->getXML();
  364. }
  365. /**
  366. * Posts cart to Google directly using CURL
  367. *
  368. * Note: lib_curl and lib_openssl must be installed
  369. * on the server to use this alternate mechanism for
  370. * posting carts to Google Checkout
  371. *
  372. * @param unknown_type $xml_cart
  373. */
  374. function postCart($xml_cart) {
  375. }
  376. //////////////////////////////////////////////
  377. // PRIVATE METHODS
  378. //////////////////////////////////////////////
  379. /**
  380. * Add Tax Tables to the cart
  381. *
  382. * @param unknown_type $name
  383. * @param unknown_type $rate
  384. * @param unknown_type $country_area
  385. * @param unknown_type $arr_states
  386. * @param unknown_type $arr_zips
  387. * @param unknown_type $standalone
  388. * @access private
  389. */
  390. function _setTaxTables($arr_tax_tables, $type = 'alternate') {
  391. /**
  392. * Add Alternate Tax Table
  393. */
  394. $str_xml = "";
  395. /**
  396. * Iterate over each tax table
  397. */
  398. foreach ($arr_tax_tables as $tax_table){
  399. $str_xml .= $tax_table->getXML();
  400. }
  401. /**
  402. * Add Tax Table XML to the cart
  403. */
  404. if($type =='alternate') {
  405. $this->_tax_tables .= "<alternate-tax-tables>$str_xml</alternate-tax-tables>";
  406. }else if($type == 'default')
  407. $this->_tax_tables .= $str_xml;
  408. }
  409. /**
  410. * Sets the Shipping objects in the cart.
  411. *
  412. * @param unknown_type $arr_shipping
  413. */
  414. function _setShipping($arr_shipping) {
  415. $str_xml = "";
  416. foreach($arr_shipping as $Shipping) {
  417. $str_xml .= $Shipping->getXML();
  418. }
  419. $this->_shipping = $str_xml;
  420. }
  421. /**
  422. * Enter description here...
  423. *
  424. * @param unknown_type $country_area
  425. * @param unknown_type $arr_states
  426. * @param unknown_type $arr_zips
  427. * @param unknown_type $type
  428. */
  429. function _getAllowedAreas($country_area, $arr_states, $arr_zips, $type="allowed"){
  430. $arr_areas = array(
  431. "$type-areas" => array()
  432. );
  433. if(!empty($country_area)) {
  434. $arr_areas["$type-areas"]['us-country-area'] = array('_attributes' => array('country-area' => $country_area));
  435. }
  436. /**
  437. * if we have states to allow / exclude
  438. */
  439. if(!empty($arr_states)) {
  440. foreach ($arr_states as $state) {
  441. /**
  442. * Bit of a hack since the XML_Serializer does not allow
  443. * more than one 'default' repeatable tags.
  444. *
  445. * Google Has decided this crazy markup
  446. */
  447. $state_data .= " <us-state-area>
  448. <state>
  449. ".$state."
  450. </state>
  451. </us-state-area>";
  452. }
  453. $arr_areas["$type-areas"] = $state_data;
  454. }
  455. /**
  456. * if we have zips to allow / exclude
  457. */
  458. if(!empty($arr_zips)) {
  459. $zip_serializer = new XML_Serializer($this->_zip_serializer_options);
  460. $zip_serializer->serialize($arr_zips);
  461. $arr_areas["$type-areas"]['us-zip-area'] = $this->_removeTag($zip_serializer->getSerializedData());
  462. }
  463. return $arr_areas;
  464. }
  465. /**
  466. * Enter description here...
  467. *
  468. * @param unknown_type $shipping_type
  469. * @param unknown_type $name
  470. * @param unknown_type $price
  471. * @param unknown_type $shipping_restrictions
  472. * @return unknown
  473. */
  474. function _getShippingArray($shipping_type, $name, $price, $allowed_restrictions = "", $excluded_restrictions = "") {
  475. /**
  476. * Check if there exists a shiping-methods
  477. */
  478. if(empty($this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods'])) {
  479. $this->_arr_shopping_cart['checkout-flow-support']['merchant-checkout-flow-support']['shipping-methods'] = array();
  480. }
  481.  
  482.  
  483. /**
  484. * Build Flat Rate Shipping Method Element
  485. */
  486. $arr_shipping_obj = array(
  487. 'price' => array(
  488. '_attributes' => array('currency' => $GLOBALS['GCheckout_currency']),
  489. '_content' => $price),
  490. '_attributes' => array('name' => $name)
  491. );
  492. /**
  493. * Add shipping restrictions (allowed / excluded)
  494. */
  495. if(!empty($allowed_restrictions)) {
  496. $arr_shipping_obj['shipping-restrictions']['allowed-areas'] = $allowed_restrictions['allowed-areas'];
  497. }
  498. if(!empty($excluded_restrictions)) {
  499. $arr_shipping_obj['shipping-restrictions']['excluded-areas'] = $excluded_restrictions['excluded-areas'];
  500. }
  501. return $arr_shipping_obj;
  502. }
  503. /**
  504. * Private: Sets the XML_Serializer Options for the GCheckout XML format
  505. *
  506. */
  507. function _setSerializerOptions() {
  508. $this->_serializer_options = array("addDecl"=> true,
  509. "indent"=>" ",
  510. "encoding" =>"UTF-8",
  511. "rootName" => 'checkout-shopping-cart',
  512. "rootAttributes" => array("xmlns"=> $GLOBALS['GCheckout_xmlSchema']),
  513. "scalarAsAttributes" => false,
  514. "attributesArray" => '_attributes',
  515. "contentName" => '_content',
  516. "defaultTagName" => 'item',
  517. "replaceEntities" => XML_SERIALIZER_ENTITIES_NONE
  518. );
  519. $this->_state_serializer_options = array("addDecl"=> false,
  520. "indent"=>" ",
  521. "rootName" => "REMOVE",
  522. "scalarAsAttributes" => false,
  523. "attributesArray" => '_attributes',
  524. "contentName" => '_content',
  525. "defaultTagName" => 'state'
  526. );
  527. $this->_zip_serializer_options = array("addDecl"=> false,
  528. "indent"=>" ",
  529. "rootName" =>"REMOVE",
  530. "scalarAsAttributes" => false,
  531. "attributesArray" => '_attributes',
  532. "contentName" => '_content',
  533. "defaultTagName" => 'zip-pattern'
  534. );
  535. $this->_state_area_serializer_options = array("addDecl"=> false,
  536. "indent"=>" ",
  537. "rootName" =>"REMOVE",
  538. "scalarAsAttributes" => false,
  539. "attributesArray" => '_attributes',
  540. "contentName" => '_content',
  541. "defaultTagName" => 'us-state-area'
  542. );
  543. $this->_alt_tax_table_serializer_options = array("addDecl"=> false,
  544. "indent"=>" ",
  545. "rootName" =>"REMOVE",
  546. "scalarAsAttributes" => false,
  547. "attributesArray" => '_attributes',
  548. "contentName" => '_content',
  549. "defaultTagName" => 'alternate-tax-table'
  550. );
  551. }
  552. /**
  553. * Private: Initializes the base shopping cart array
  554. *
  555. */
  556. function _setShoppingCart() {
  557. $this->_arr_shopping_cart = array(
  558. 'shopping-cart' => array(),
  559. 'checkout-flow-support' => array(
  560. 'merchant-checkout-flow-support' => array()
  561. )
  562. );
  563. }
  564. /**
  565. * Hash function that computes HMAC-SHA1 value.
  566. * This function is used to produce the signature
  567. * that is reproduced and compared on the other end
  568. * for data integrity.
  569. *
  570. * @param $data message data
  571. * @param $merchant_key secret Merchant Key
  572. * @return $hmac value of the calculated HMAC-SHA1
  573. */
  574. function _getHmacSha1($data, $merchant_key) {
  575. $blocksize = 64;
  576. $hashfunc = 'sha1';
  577. if (strlen($merchant_key) > $blocksize) {
  578. $merchant_key = pack('H*', $hashfunc($merchant_key));
  579. }
  580. $merchant_key = str_pad($merchant_key, $blocksize, chr(0x00));
  581. $ipad = str_repeat(chr(0x36), $blocksize);
  582. $opad = str_repeat(chr(0x5c), $blocksize);
  583. $hmac = pack(
  584. 'H*', $hashfunc(
  585. ($merchant_key^$opad).pack(
  586. 'H*', $hashfunc(
  587. ($merchant_key^$ipad).$data
  588. )
  589. )
  590. )
  591. );
  592. return $hmac;
  593. }
  594. /**
  595. * Enter description here...
  596. *
  597. * @param unknown_type $input
  598. * @return unknown
  599. */
  600. function _removeTag($input) {
  601. return str_replace($this->_remove_tags,"", $input);
  602. }
  603. /**
  604. * CODE BORROWED FROM GOOGLE'S SAMPLE CODE
  605. * - Thanks Google!!
  606. *
  607. * The GetCurlResponse function sends an API request to Google Checkout
  608. * and returns the response. The HTTP Basic Authentication scheme is
  609. * used to authenticate the message.
  610. *
  611. * This function utilizes cURL, client URL library functions.
  612. * cURL is supported in PHP 4.0.2 or later versions, documented at
  613. * http://us2.php.net/curl
  614. *
  615. * @param $request XML API request
  616. * @param $post_url URL address to which the request will be sent
  617. * @return $response synchronous response from the Google Checkout
  618. * server
  619. */
  620. function _getCurlResponse($request, $post_url) {
  621. /**
  622. * Check if Curl is installed
  623. */
  624. if(!function_exists('curl_setopt'))
  625. return false;
  626. $ch = curl_init();
  627. curl_setopt($ch, CURLOPT_URL, $post_url);
  628. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  629. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, VALIDATE_MY_SSL_CERT);
  630. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, VALIDATE_GOOGLE_SSL_CERT);
  631. /*
  632. * This "if" block, which sets the HTTP Basic Authentication scheme
  633. * and HTTP headers, only executes for Order Processing API requests
  634. * and for server-to-server Checkout API requests.
  635. */
  636. // Set HTTP Basic Authentication scheme
  637. curl_setopt($ch, CURLOPT_USERPWD, $this->_mercant_id .
  638. ":" . $this->_mercant_key);
  639. // Set HTTP headers
  640. $header = array();
  641. $header[] = "Content-type: application/xml";
  642. $header[] = "Accept: application/xml";
  643. $header[] = "Content-Length: ".strlen($request);
  644. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  645. curl_setopt($ch, CURLOPT_POST, 1);
  646. curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  647. // Execute the API request.
  648. $response = curl_exec($ch);
  649. /*
  650. * Verify that the request executed successfully. Note that a
  651. * successfully executed request does not mean that your request
  652. * used properly formed XML.
  653. */
  654. if (curl_errno($ch)) {
  655. /* Do Something */
  656. echo "A problem occured when posting your cart to google <br/>";
  657. echo "CURL_ERROR: ".curl_errno($ch);
  658. return false; /* No Open SSL */
  659. } else {
  660. curl_close($ch);
  661. }
  662. // Return the response to the API request
  663. return $response;
  664. }
  665.  
  666. } // END CLASS DEFINITION
  667. ?>

Documentation generated on Mon, 04 Dec 2006 11:09:29 -0500 by phpDocumentor 1.3.0RC3