slhemanthkumar / google-checkout-php-sample-code

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

In response getting 400 bad request #63

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. requested url is 
https://sandbox.google.com/checkout/view/buy?o=shoppingcart&shoppingcart=2060916
07476087.
2. After purchase done my response is empty and getting 400 bad request.
3. I want to redirect automatically to my site.Listed under is my response code 
which i have use in calllbackurl.
/* Checkout Code */
$cart = new GoogleCart($this->merchant_id, $this->merchant_key, 
$this->server_type, $this->currency);

        $mpd = new MerchantPrivateData($customData);
        $cart->SetMerchantPrivateData($mpd);

        if(isset($customData['txnType']))   {
            $transactionType = $customData['txnType'];
        }   else    {
            $transactionType = "Investment";
        }

        $item = new GoogleItem($transactionType, $customData['cause'], $amount_of_shares, $price_per_share);

        $item->SetURLDigitalContent(Router::url('/users/index/', true), "", "");
        $cart->AddItem($item);

        $cart->CheckoutServer2Server();
/* Checkout End*/
/* Response Code */

        $post = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : file_get_contents("php://input");

        $response = new GoogleResponse($this->merchant_id, $this->merchant_key);
        $response->SetLogFiles(RESPONSE_HANDLER_ERROR_LOG_FILE, RESPONSE_HANDLER_LOG_FILE, L_ALL);

        list($root, $data) = $response->GetParsedXML($post);
        print_r($root);exit;
        switch ($root) :

            case "charge-amount-notification" : {

                $response->SendAck();
                break;

            }

            case "merchant-calculation-callback" : {    
                break;
            }

            case "new-order-notification" : {

                $this->GoogleUpdateOrders($data[$root]);

                break;

            }

            case "order-state-change-notification" : {

                if ($data[$root]["previous-financial-order-state"]["VALUE"] == "CHARGING" && $data[$root]["new-financial-order-state"]["VALUE"] == "CHARGED") :

                    $this->updateFinancialOrderState($data[$root]);

                elseif ($data[$root]["new-financial-order-state"]["VALUE"] == "CANCELLED") :

                    $this->cancelOrder($data[$root]);

                endif;

                $response->SendAck();

            break;

            }

            case "refund-amount-notification" : {

                $response->SendAck();

                break;

            }

            case "risk-information-notification" : {

                $response->SendAck();

                break;

            }

            default : {

                $response->SendBadRequestStatus("An error occurred.");

                break;

            }

        endswitch;

        $res = ob_get_contents();

        $fh = fopen(WWW_ROOT . 'logs' . DS . 'google_log.txt', "w");
        fwrite($fh, $res);
        fclose($fh);
/* Response Code End */
Output:"An error occurred."

Operating System:Ubuntu,PHP:"5.2.4-2".

Please assist me on this ASAP.

Original issue reported on code.google.com by spsspanw...@gmail.com on 16 Sep 2011 at 5:30