I've integrated Google Checkout with a site, got it working / pretending to charge people fine and also processing the order notifications fine.
However, when I make a request back to Google to get the details of the notification, I receive a 400 response, something about invalid XML.
Thing is, everything for this integration so far has been HTML key value pairs, but all of a sudden I need to parse and deal with XML? I may be missing something, but I can't see where in the docs it tells me exactly what my request should look like.
It clearly lists an example with name / value pairs, yet apparently I actually need to send them as XML?
Here's where I am right now:
<?php $header_arr = array("Authorization: Basic ".$authKey,
"Content-Type: application/xml; charset=UTF-8",
"Accept: application/xml; charset=UTF-8");
$request='type=notification-history-request&serial-number='.$serialNumber;
$ch = curl_init($test_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_arr);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$body = curl_exec($ch);
if (curl_errno($ch)) {
$log.=', error! :'.curl_error($ch);
} else {
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$log.=', status code is: '.$status_code; //400
}
?>
This returns a 400 each time - yes I realise I'm setting an accept header for XML, this is as the docs specify, here: http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API.html#https_auth_scheme
So, I find myself needing to send the correct request... any ideas?
P.S I've also checked through google's sample code but it's so layered and dependency-ridden that while I've managed to use some of it, the rest is a mystery - so unless you can give me line numbers, the samples aren't much help