yousaf009 / google-checkout-php-sample-code

Automatically exported from code.google.com/p/google-checkout-php-sample-code
0 stars 0 forks source link

GoogleRequest->SendReq should attempt to return error-message elements rather than raw messages #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently GoogleRequest->SendReq() will return a result body which is simply 
the entire HTTP 
response run through htmlentities. The change below uses SimpleXML to parse the 
response - if 
successful it returns only the error-message; otherwise it fails back to the 
current approach. 

      $b_x = $this->get_body_x($response);

            $body = htmlentities($b_x);

            // Attempt to replace XML blob with an error-message element if the response 
contains one:
            try {
                $b_e = new SimpleXMLElement($b_x);
                if ($b_e and !empty($b_e->{'error-message'})) {
                    $body = implode(",\n", $b_e->{'error-message'}->getChildren());
                }
            } catch (Exception $e) {
                $body = htmlentities($b_x);
            }

      // Get HTTP Status code from the response
      $status_code = array();
      preg_match('/\d\d\d/', $heads[0], $status_code);

      // Check for errors
      switch( $status_code[0] ) {
        case 200:
          // Success
            $this->log->LogResponse($response);          
            return array(200, $body);
          break;

Original issue reported on code.google.com by adamsc@gmail.com on 10 May 2008 at 12:59

GoogleCodeExporter commented 8 years ago
how can we set the redirect url to our site

Original comment by naginiko...@gmail.com on 6 Jun 2008 at 1:48

GoogleCodeExporter commented 8 years ago
I am also interested to know how can we set the redirect url to our site

http://www.carazoo.com/

Original comment by izmocars...@gmail.com on 4 Mar 2009 at 7:10

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
will be updated in next release

Original comment by peng.y...@gmail.com on 13 Sep 2010 at 6:18