0
votes

I'm trying to send Google Checkout a Notification Acknowledgement once I receive a serial number so it would know that I've already handled this serial number and saved it to my database. But I keep getting the following error in the integration console:

We encountered an error processing your notification acknowledgment. The error we got is: Error parsing notification acknowledgment.

When I check the value being sent to the server, everything seems to look fine to me:

<notification-acknowledgement xmlns="http://checkout.google.com/schema/2" serial-number="357304636821412-00001-7" />

Here's my code:

    [HttpPost]
    public EmptyResult Notify()
    {
        var serial = Request["serial-number"];
        var data =
            "<notification-history-request xmlns=\"http://checkout.google.com/schema/2\"><serial-number>" + serial + "</serial-number></notification-history-request>";
        var serverResponse = _checkoutService.Post(data, GoogleCheckoutConstants.ReportsUri);

        //Send me email to checkout the response
        dynamic email = new Email("CheckoutLog");
        email.Response = serverResponse;
        email.Send();

        var acknowldgement =
            "<notification-acknowledgement xmlns=\"http://checkout.google.com/schema/2\" serial-number=\"" + serial +
            "\" />";

        HttpResponse response = System.Web.HttpContext.Current.Response;
         response.StatusCode = 200;
         response.ContentType = "text/xml";
        response.Write(acknowldgement);
        return null;
    }

Moreover, why do I keep receiving new-order-notification only? What's more important to me is the authorization-amount-notification, but it never sends it although in the Documentation Section 2, Step 2.1 it says that after some time it should send me this notification. Am I missing something here?

3
Did you try Response.Flush()?joe.feser

3 Answers

2
votes

Seems you are missing xml declaration(?)

**<?xml version="1.0" encoding="utf-8"?>**
<notification-acknowledgment serial-number="the-serial-no" xmlns="http://checkout.google.com/schema/2" />

Other things that could also affect it (guess based only on the above):

  • an exception in your call to _checkoutService.Post
  • an exception in your call to email.Send()

It might be better if you first store the serial # (so you "always" have it), and then do whatever else you need to do (i.e. send the notification history request, parse, send email, etc.).

The idea of the acknowledgement is for you to acknowledge successful receipt of the serial number. Once you have the serial number you can perform notification history request(s) whenever you need to (i.e. if you have issues parsing you can always resend over and over until you can parse successfully).

Hope this helps....

0
votes

Why are you not using the .Net library that was already built for Google Checkout.

See this for more info.

http://code.google.com/p/google-checkout-dotnet-sample-code/

0
votes

You also need to make sure that you are referring to the correct API version in the documentation and the sample code. I was looking at two different versions and it was confusing me big time. If you are using the api version 2.5 checkout out this post.

http://www.capprime.com/software_development_weblog/2010/11/29/UsingTheGoogleCheckout25APIWithASPNETMVCTheMissingSample.aspx