slhemanthkumar / google-checkout-php-sample-code

Automatically exported from code.google.com/p/google-checkout-php-sample-code
0 stars 0 forks source link

PHP running with FastCGI server API "Failed to Get Basic Authentication Headers" #64

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Google checkout sends response to cart

What is the expected output?

The response from Google should be accepted. 

What do you see instead?

Google checkout receives error "Failed to get basic authentication headers"

What version of the product are you using?

7541 2011-07-07 08:51:35Z gBrunier

On what operating system?

FreeBSD 8.2-STABLE #0 amd64, server api: CGI/FastCGI, php 5.3.6, Apache 2.2.20

Please provide any additional information below.

Using prestashop 1.4.3 and this is how I worked around this issue.

create .htaccess file in /modules/gcheckout/.htaccess

<IfModule mod_rewrite.c>
RewriteBase /modules/gcheckout/library
RewriteCond %{HTTP:Authorization} !^$
RewriteRule validation.php 
validation.php?HTTP_AUTHORIZATION=%{HTTP:Authorization} [QSA,L]
</IfModule>

modify HttpAuthentication function in  
/modules/gcheckout/library/googleresponse.php

function HttpAuthentication($headers=null, $die=true) {
    if (!is_null($headers)) {
        $_SERVER = $headers;
    }

    list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_GET['HTTP_AUTHORIZATIOIZATION'], 6)));

    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'];

        unset($_SERVER['PHP_AUTH_USER']);
        unset($_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).
    elseif (isset($_SERVER['HTTP_AUTHORIZATION'])){
        list($compare_mer_id, $compare_mer_key) = explode(':',
        base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'],
        strpos($_SERVER['HTTP_AUTHORIZATION'], " ") + 1)));
    } elseif (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;
}

Original issue reported on code.google.com by sven.sve...@gmail.com on 12 Oct 2011 at 7:34