Hello,

I am running Ubertcart 2.x RC6 with Google Checkout as the payment processor. Put simply, I keep receiving e-mails from Google Checkout informing me that there is a problem with the integration between Ubercart and Google Checkout. The e-mail says:

We've made several unsuccessful attempts to send order notifications to your notification callback URL, https://mydomain.org/google_checkout As a result, you aren't receiving order status, risk, or other notifications.

When I visit the URL for my callback, the following error appears:

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in sites/all/modules/ubercart/payment/uc_google_checkout/uc_google_checkout.pages.inc:30 Stack trace: #0
sites/all/modules/ubercart/payment/uc_google_checkout/uc_google_checkout.pages.inc(30): SimpleXMLElement->__construct('') #1 [internal function]: uc_google_checkout_callback() #2
includes/menu.inc(348): call_user_func_array('uc_google_check...', Array) #3
index.php(18): menu_execute_active_handler() #4 {main} thrown in
sites/all/modules/ubercart/payment/uc_google_checkout/uc_google_checkout.pages.inc on line 30

Some additional information:

1. I configured uc_google_checkout exactly per the instructions from Ubercart's docs section

2. I purchased and installed a security certificate on my dedicated server from GoDaddy that appears to be supported by Google Checkout.

3. Per the docs, I downloaded and installed the SecurePages module to make the https://mydomain.org/google_checkout link secure.

4. In Google Checkout's Integration settings, I am using XML as opposed to HTML, per the docs.

Can anyone offer some advice as to what's going on and how I can fix it?

Thanks

Comments

eusebius’s picture

Some additional information I discovered a moment ago from the system log:

SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in /sites/all/modules/ubercart/payment/uc_google_checkout/uc_google_checkout.pages.inc on line 30.

eggersrj’s picture

Eusebius, were you able to figure this out?

I have the same problem.

wrightnow’s picture

I'm having the same issue - payment goes through on a GC payment, but Drupal site has no idea what's going on since the callback doesn't work...

** Update **

I patched the NPE, which was happening when I manually loaded the page since there was no xml parameter being set. Turns out the issue with google was the certificate not being installed correctly. Google->tools->integration center gave more insight.

mimetic2’s picture

I also have this problem.

eusebius’s picture

jww2nc,

What's the NPE? I followed your lead and double checked my cert using openssl, but everything seems to check out okay, except for this one message at the top:

CONNECTED(00000003)
depth=3 /L=ValiCert Validation Network/O=ValiCert, Inc./OU=ValiCert Class 2 Policy Validation Authority/CN=http://www.valicert.com//emailAddress=info@valicert.com
verify error:num=19:self signed certificate in certificate chain
verify return:0

Thanks for the help

wrightnow’s picture

Just to make sure I'm clear - the NPE catch I put in doesn't fix the overall problem (which in my case was a certificate issue with our site host), but simply catches the NPE produced if the input isn't well-formed XML and the SimpleXMLElement constructor crashes. It's probably not vital, which is why I never published it. But my changes are in uc_google_checkout.pages.inc and affect the function uc_google_checkout_callback(). See below for the entire altered method.

function uc_google_checkout_callback() {
    if (variable_get('uc_google_checkout_mode', 'checkout') == 'checkout') {
        $merchant_id = variable_get('uc_google_checkout_merchant_id', '');
        $merchant_key = variable_get('uc_google_checkout_merchant_key', '');
    }
    else {
        $merchant_id = variable_get('uc_google_checkout_test_merchant_id', '');
        $merchant_key = variable_get('uc_google_checkout_test_merchant_key', '');
    }

    //watchdog('google', check_plain($_SERVER['PHP_AUTH_USER']), NULL, WATCHDOG_NOTICE);
    if ($_SERVER['PHP_AUTH_USER'] != $merchant_id) {
        watchdog('google', 'HTTP Authorization User does not match settings.', array(), WATCHDOG_ERROR);
    }
    //watchdog('google', check_plain($_SERVER['PHP_AUTH_PW']), NULL, WATCHDOG_NOTICE);
    if ($_SERVER['PHP_AUTH_PW'] != $merchant_key) {
        watchdog('google', 'HTTP Authorization Password does not match settings.', array(), WATCHDOG_ERROR);
    }
    $input = file_get_contents('php://input');
    //watchdog('google', print_r(check_plain($input), TRUE), NULL, WATCHDOG_NOTICE);
    try {
        $xml = new SimpleXMLElement($input);
    }
    catch (Exception $e) {
        echo('error!');
        print('error');
           watchdog('google', 'Unknown notification document: @xml', array('@xml' => $input), WATCHDOG_ERROR);
            $output = uc_google_checkout_notification_acknowledgement($xml->{'serial-number'});
    }


    switch ($xml->getName()) {
        case 'merchant-calculation-callback':
        //uc_google_checkout_merchant_calculation($xml);
            break;
        case 'new-order-notification':
            uc_google_checkout_new_order($xml);
            break;
        case 'order-state-change-notification':
            uc_google_checkout_order_state_change($xml);
            break;
        case 'risk-information-notification':
            uc_google_checkout_accept_risk($xml);
            break;
        case 'charge-amount-notification':
            uc_google_checkout_charge_order($xml);
            break;
        case 'refund-amount-notification':
            uc_google_checkout_refund_order($xml);
            break;
        default:
            watchdog('google', 'Unknown notification document: @xml', array('@xml' => $input), WATCHDOG_ERROR);
            $output = uc_google_checkout_notification_acknowledgement($xml->{'serial-number'});
    }
}
danharper’s picture

I also have this problem, I keep getting e-mails from google saying they can't contact my callback api.

Is there a fix for this or can I request my host to setup my certificate differently?

Cheers Dan

wrightnow’s picture

In our case, the issue was SSL cert based - my patch just gets UC to handle the error more gracefully.

patoshi’s picture

same problem here.. what is NPE? and do i need to patch anything with the module or is this due to my configuration?

doofaye’s picture

anyone worked this out yet ?

I reckon either SSl certificate not supported or mis configured by host.

Can anyone explain to me what the error message actually means?

thepuzzlemaster’s picture

Has anyone figured this out yet? Or does anyone have any insight into a work around? I am having the exact same problem with a certificate from a trusted source. Exact same symptoms...

patoshi’s picture

same problem here.. anyone resolve this?

Melissamcewen’s picture

Has anyone figured this out? Any help is appreciated!

BrianLewisDesign’s picture

Same problem here. Need the Google Checkout callback to work. Urgent. Google checkout is useless without the call back.

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new16.49 KB

Google Checkout's API version is now 2.5, so I have modified the code to reflect this. One of the changes was the way notifications were handled. Now, you don't need an SSL certificate on your site because Google just sends a serial number. The site is then supposed to send a notification request containing that serial number, and all of the other authentication parameters as normal.

For any existing GCO integrations, this means you have to change your settings in the Merchant Center to keep receiving notifications. Under the Settings tab, click Integration on the left side. Change "Callback contents" to "Notification Serial Number" and API version to 2.5.

Island Usurper’s picture

Version: 6.x-2.0-rc6 » 6.x-2.x-dev
Status: Needs review » Fixed
StatusFileSize
new16.77 KB

I committed #757604: Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed', so this patch needed a reroll. I also realized that it would be a very good idea to specify the Notification content and API version that we expect.

I've been using this in production for a while now, so with correct configuration, it should work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

larowlan’s picture

Added some doco http://drupal.org/node/1187830 as finding this patch earlier could have saved some time.