I am getting back the following response from a charge-amount-notification. (in the sandbox env). What I am trying to do is to send an e-mail alert to a customer when I am certain the payment is cleared. Right now I am using new-order-notification and sometimes customers payments will fail and I want to make sure I am delivering the digital download when I get the money.
array (
'charge-amount-notification' =>
array (
'xmlns' => 'http://checkout.google.com/schema/2',
'serial-number' => '962015304346298-00013-2',
'timestamp' =>
array (
'VALUE' => '2012-09-01T13:25:18.732Z',
),
'latest-charge-amount' =>
array (
'currency' => 'USD',
'VALUE' => '99.0',
),
'total-charge-amount' =>
array (
'currency' => 'USD',
'VALUE' => '99.0',
),
'google-order-number' =>
array (
'VALUE' => '962015304346298',
),
),
)
I was expecting an order-summary key with customer information as described in documentation.
Here is my code:
if (isset($_POST['serial-number']))
{
require_once('lib/google_checkout/googleresponse.php');
require_once('lib/google_checkout/googlerequest.php');
require_once('lib/google_checkout/googlenotificationhistory.php');
$response = new GoogleResponse(GOOGLE_MERCHANT_ID, GOOGLE_MERCHANT_KEY);
$google_notification_history = new GoogleNotificationHistoryRequest(GOOGLE_MERCHANT_ID, GOOGLE_MERCHANT_KEY, GOOGLE_SANDBOX ? 'sandbox' : 'production');
$raw_xml_array = $google_notification_history->SendNotificationHistoryRequest($_POST['serial-number']);
$raw_xml = $raw_xml_array[1];
$response->SendAck($_POST['serial-number'], false);
list($root, $order_data) = $response->GetParsedXML($raw_xml);
if (isset($order_data['charge-amount-notification']))
{
$data = array();
file_put_contents("google.txt", var_export($order_data, true));
$data['name'] = $order_data['charge-amount-notification']['order-summary']['buyer-billing-address']['contact-name']['VALUE'];
$data['email'] = $order_data['charge-amount-notification']['order-summary']['buyer-billing-address']['email']['VALUE'];
$data['txn_id'] = $order_data['charge-amount-notification']['google-order-number']['VALUE'];
$data['payment_status'] = 'Completed';
$res = save_payment($data);
if ($res) {
$data = payment_details(array('txn_id' => $data['txn_id']));
mail_notification($data);
}
}
}
The
<order-summary>element is included in notifications only with the 2.5 API version.The Google Checkout HTML API Notification API states: