예제 #1
0
$xp->setDocument($doc);
$xp->parse($xml_response);
$doc = $xp->getDocument();
if (is_object($doc->root)) {
    $root = $doc->getRoot();
    $message_recognizer = $root->getName();
} else {
    fn_google_xml_error('GCC: failed to parse incoming XML');
}
if ($message_recognizer != 'merchant-calculation-callback') {
    fn_google_xml_error('GCC: incoming XML is not that we are expecting');
}
// Restart session
$google_sess_id = $root->getValueByPath('shopping-cart/merchant-private-data/additional_data/session_id');
if (empty($google_sess_id)) {
    fn_google_xml_error('GCC: failed to get session ID from XML');
}
Session::reset_id($google_sess_id);
$_SESSION['cart'] = empty($_SESSION['cart']) ? array() : $_SESSION['cart'];
$cart =& $_SESSION['cart'];
$currency_code = $root->getValueByPath('shopping-cart/merchant-private-data/additional_data/currency_code');
$response = array();
$adr = $root->getElementByPath('calculate/addresses');
$cds = $root->getElementByPath('calculate/merchant-code-strings');
if ($adr) {
    $addresses = $adr->getElementsByName('anonymous-address');
}
if ($cds) {
    $_codes = array();
    $codes = $cds->getElementsByName('merchant-code-string');
}
        fn_change_order_status($order_id, 'P', '', false);
    }
    fn_change_google_info($order_id, array('charged_amount' => $amount));
    fn_sendnotification_acknowledgment($schema_url);
} elseif ($message_recognizer == 'refund-amount-notification') {
    $order_id = db_get_field("SELECT order_id FROM ?:order_data WHERE type = 'E' AND data = ?s", $transaction_id);
    if (empty($order_id)) {
        fn_google_xml_error("GCR[charge-amount-notification]: Failed to get order_id by google-order-number ({$transaction_id})");
    }
    $amount = $root->getValueByPath('/total-refund-amount');
    fn_change_google_info($order_id, array('refunded_amount' => $amount, 'financial_state' => 'REFUNDED'));
    fn_sendnotification_acknowledgment($schema_url);
} elseif ($message_recognizer == 'chargeback-amount-notification') {
    $order_id = db_get_field("SELECT order_id FROM ?:order_data WHERE type = 'E' AND data = ?s", $transaction_id);
    if (empty($order_id)) {
        fn_google_xml_error("GCR[charge-amount-notification]: Failed to get order_id by google-order-number ({$transaction_id})");
    }
    $amount = $root->getValueByPath('/total-chargeback-amount');
    fn_change_google_info($order_id, array('chargeback_amount' => $amount));
    fn_sendnotification_acknowledgment($schema_url);
}
// The SendNotificationAcknowledgment function responds to a Google Checkout
// notification with a <notification-acknowledgment> message. If you do
// not send a <notification-acknowledgment> in response to a Google Checkout
// notification, Google Checkout will resend the notification multiple times.
function fn_sendnotification_acknowledgment($schema_url)
{
    $acknowledgment = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "<notification-acknowledgment xmlns=\"" . $schema_url . "\"/>";
    echo $acknowledgment;
}
function fn_prepare_to_place_order(&$xml_data, &$cart, &$auth)