Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:06:55+00:00 2026-06-10T23:06:55+00:00

I’m trying to figure out how to get this working with PHP. I have

  • 0

I’m trying to figure out how to get this working with PHP. I have a working IPN for paypal that is less than 20 lines of code to get the data I need. I have tried reading the Google docs but they are either way too specific or way too general. There is some sample code, which is about 1300 lines in 5 files and I can’t make sense of it. I just need a handful of vars back from a completed transaction, nothing more. Is it possible to do this with a few lines of code (and I mean without 1300 lines worth of “include” files) or is Google Checkout’s process really that bulky?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:06:57+00:00Added an answer on June 10, 2026 at 11:06 pm

    I’ve gotten it to work, and here’s the skeleton of my code that can be used to handle HTTP notifications/responses. This was obviously derived from tntu’s example above. (Thanks!)

    //incoming data is in the var $_POST['serial-number']
    //"send" the response to acknowledge the serial number that google talks about all over but never explains how
    echo "_type=notification-acknowledgment&serial-number=".$_POST['serial-number'];
    
    //now we need to call google's server and ask for this transaction's data:
    //you'll need to change your merchant id in the $url and $mid vars, and your merchant key in the $mky var
    $url = "https://sandbox.google.com/checkout/api/checkout/v2/reportsForm/Merchant/1234567890?_type=notification-history-request&serial-number=" . $_REQUEST['serial-number'];
    $mid = "1234567890"; 
    $mky = "ABCDEFGHIJK";
    $aut = base64_encode($mid . ":" . $mky);
    
    $arr = parse_url($url);
    $ssl = "";
    if($arr['scheme'] == "https") $ssl = "ssl://";
    
    $post  = "POST " . $arr['path'] . " HTTP/1.1\r\n";
    $post .= "Host: " . $arr['host'] . "\r\n";
    $post .= "Authorization: Basic " . $aut . "\r\n";
    $post .= "Content-Type: application/xml; charset=UTF-8\r\n";
    $post .= "Accept: application/xml; charset=UTF-8\r\n";
    $post .= "Content-Length: " . strlen($arr['query']) . "\r\n";
    $post .= "Connection: Close\r\n";
    $post .= "\r\n";
    $post .= $arr['query'];
    
    //now we actually make the request by opening a socket and calling Google's server
    $f = fsockopen($ssl . $arr['host'], 443, $errno, $errstr, 30);
    
    if(!$f){
        //something failed in the opening of the socket, we didn't contact google at all, you can do whatever you want here such as emailing yourself about it and what you were trying to send, etc
        @mail("troubleshooting@yourdomain.com","Google IPN - HTTP ERROR ",$errstr . " (" . $errno . ")\n\n\n".$arr['query']);
    }else{
        //the socket was opened, send the request for the order data: 
        fputs($f, $post); // you're sending
        while(!feof($f)) { $response .= @fgets($f, 128); } //google replies and you store it in $response
        fclose($f); //close the socket, we're done talking to google's server
    
        $spl=strpos($response,"_type="); //parse the type because parse_str won't catch it
        if ($spl!==false){
            $spl2=strpos($response,"&",$spl);
            $ordertype=substr($response,($spl+6),($spl2-$spl)-6);
        }//$ordertype will tell you which type of notification is being sent, new-order-notification, risk-information-notification, etc
        $subresponse=substr($response,$spl2+1); //put the rest of it into an array for easy access
        parse_str($subresponse,$order);//you can now access google's response in $order[] vars
        //IMPORTANT: dots in Google's field names are replaced by underscore, for example:
        // $order['google-order-number'] and $order['buyer-billing-address_address1'] NOT $order['buyer-billing-address.address1']
        //order field names are shown here: 
        //https://developers.google.com/checkout/developer/Google_Checkout_HTML_API_Notification_API#order_summary
    
         //this is the point where you will want to use the data contained in $order[] to create a new record in your database or whatever.
        //NOTE: be sure to store and check for duplicates using the google-order-number because you will get multiple notifications from google regarding the same order
    
        if (strtoupper($order['order-summary_financial-order-state']) == "CHARGEABLE"){
            //CHARGEABLE is what indicates it is safe to create a login for the user (if you are delivering digital goods) 
            // insert into db, and/or email user with key or download url
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.