Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Google Checkout - API Callback URL - Error - Failed to Get Basic Authentication
 
etho201
Sr. Member
 
Total Posts:  85
Joined:  2008-04-03
Summerville, SC
 

Maybe I am not doing this correctly, but I can’t seem to get this to work. I looked at the wiki for Google Checkout and followed it exactly. I have SSL enabled on my site… and I entered the API Callback URL as: https://secure.omnivariety.com/googlecheckout/api

Then when I look at my integration console in google checkout I keep getting the following error.

We encountered an error trying to access your server at https://secure.omnivariety.com/googlecheckout/api/—the error we got is: Sending failed with HTTP response code: 401. Response body was: Failed to Get Basic Authentication Headers

Then it says, “XML We Sent:” with the following code.

<?xml version="1.0" encoding="UTF-8"?>
<merchant-calculation-callback xmlns="http://checkout.google.com/schema/2" serial-number="f684380d-r2d2-456d-a8b1-f3ad3f2bb5b1">
  <
shopping-cart>
    <
items>
      <
item>
        <
item-weight value="2.0" unit="LB" />
        <
tax-table-selector>2</tax-table-selector>
        <
item-name>Sample Product B</item-name>
        <
item-description></item-description>
        <
quantity>1</quantity>
        <
unit-price currency="USD">29.95</unit-price>
        <
merchant-item-id>10123-Blue-Medium</merchant-item-id>
        <
merchant-private-item-data>
          
                
          <
quote-item-id>299</quote-item-id>
          
            
        </
merchant-private-item-data>
      </
item>
    </
items>
    <
merchant-private-data>
      
                
      <
quote-id>69</quote-id>
      
            
    </
merchant-private-data>
  </
shopping-cart>
  <
buyer-id>371336154727225</buyer-id>
  <
calculate>
    <
addresses>
      <
anonymous-address id="361827037938980">
        <
country-code>US</country-code>
        <
city>Charleston</city>
        <
region>SC</region>
        <
postal-code>29404</postal-code>
      </
anonymous-address>
    </
addresses>
    <
shipping />
    <
tax>true</tax>
    <
merchant-code-strings />
  </
calculate>
  <
buyer-language>en_US</buyer-language>
</
merchant-calculation-callback>

Any ideas on how to fix that? :?

 
Magento Community Magento Community
Magento Community
Magento Community
 
etho201
Sr. Member
 
Total Posts:  85
Joined:  2008-04-03
Summerville, SC
 

I finally got this to work!!! I don’t know how serious a security threat this presents, but here is what I did.

Open:
/public_html/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php

Delete lines 47 - 51:

$status $this->getGResponse()->HttpAuthentication();

        if (!
$status || empty($data[$root])) {
            
exit;
        
}

Open:
/public_html/lib/googlecheckout/googleresponse.php

Delete lines 73 - 119:

/**
     * Verifies that the authentication sent by Google Checkout matches the
     * merchant id and key
     *
     * @param string $headers the headers from the request
     */
    function HttpAuthentication($headers=null$die=true{
      
if(!is_null($headers)) {
        $_SERVER 
$headers;
      
}
      
// moshe's fix for CGI
      
if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
          
foreach ($_SERVER as $k=>$v{
              
if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) {
                  $_SERVER[
'HTTP_AUTHORIZATION'$v;
                  break;
              
}
          }
      }

      
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
        $compare_mer_id 
$_SERVER['PHP_AUTH_USER'];
        
$compare_mer_key $_SERVER['PHP_AUTH_PW'];
      
}

  
//  IIS Note::  For HTTP Authentication to work with IIS,
  // the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
      
else if(isset($_SERVER['HTTP_AUTHORIZATION'])){
        
list($compare_mer_id$compare_mer_key) = explode(':',
            
base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'],
            
strpos($_SERVER['HTTP_AUTHORIZATION']" ") + 1)));
      
else if(isset($_SERVER['Authorization'])) {
        
list($compare_mer_id$compare_mer_key) = explode(':',
            
base64_decode(substr($_SERVER['Authorization'],
            
strpos($_SERVER['Authorization']" ") + 1)));
      
else {
        $this
->SendFailAuthenticationStatus(
              
"Failed to Get Basic Authentication Headers",$die);
        return 
false;
      
}
      
if($compare_mer_id != $this->merchant_id
         
|| $compare_mer_key != $this->merchant_key{
        $this
->SendFailAuthenticationStatus("Invalid Merchant Id/Key Pair",$die);
        return 
false;
      
}
      
return true;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
ForgetHangovers
Sr. Member
 
Total Posts:  83
Joined:  2009-04-12
Maryland, USA
 

I am also getting “Failed to Get Basic Authentication” errors in my /var/log/googleerror.log

Is the “carrier calculated shipping” working for you now etho201?

I don’t know how I feel about chopping bits of code out of the core google API code.
Anyone found another alternative?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top