slhemanthkumar / google-checkout-php-sample-code

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

Redirect URL is blank after cart submission - Bug in googleresponse.php SendRequest #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When doing server-2-server API 2.5 cart submissions with demo code 1.3.1, the 
GoogleCart.CheckoutServer2Server function returns a status code of 200 but the 
redirect URL is blank.

The GoogleRequest.SendReq function returns the status code and the xml around 
line 740:

return array(200, $body);

but $body is empty.

The problem is caused by a bug in GoogleRequest.SendReq approx line 718. The 
$body variable is only initialized if the XML contains errors. Otherwise it is 
left blank, thus the redirect URL is not returned.

Here is the fixed code:

try {
 $b_e = new SimpleXMLElement($body_xml);
 if ($b_e and !empty($b_e->{'error-message'})) {
   $body = implode(",\n", $b_e->{'error-message'}->getChildren());
 } else {
   $body = $body_xml;
 }
} catch (Exception $e) {
 //$body = htmlentities($b_x);
 error_log("Exception processing server response: ".$e);
} 

Original issue reported on code.google.com by ChrisTre...@googlemail.com on 11 May 2011 at 10:28

GoogleCodeExporter commented 9 years ago
This solved the problem for me. Thank you.

Original comment by merch...@savvywebstrategy.com on 15 Feb 2012 at 8:39

GoogleCodeExporter commented 9 years ago
Actually - see issue 61 which seems to be the same issue and reflects the 
change in v1.3.3 to fix this problem

Original comment by rwap.services on 28 Aug 2012 at 9:53