问题
I have a callback url that gets called, and I can process it. However - Google doesn't process my acknowledgment. This is all in EnvironmentType.Sandbox
.
In the Google checkout "Integration Console" I get the following message:
We encountered an error processing your notification acknowledgment. The error we got is: Error parsing notification acknowledgment.
And the details are:
What they sent me: serial-number=...
.
What they received:
<?xml version="1.0" encoding="utf-8"?>
<notification-acknowledgment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serial-number="here is the same serial number they sent me" xmlns="http://checkout.google.com/schema/2" />
<!DOCTYPE html...
The code I'm using:
GCheckout.AutoGen.NotificationAcknowledgment response = new GCheckout.AutoGen.NotificationAcknowledgment();
response.serialnumber = serialNumber;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(GCheckout.Util.EncodeHelper.Serialize(response));
HttpContext.Current.Response.StatusCode = 200;
What's the mistake here?
回答1:
See this "code behind" code from the .Net Library examples
If you are using an aspx file, remove all the HTML content in it as shown in aspx
source of the same example
Response.End()
will also work because it stops any further Reponse content from being returned (effectively does the same thing - prevents the HTML content in the Web Forms (aspx
file) from being sent).
You can also consider using a generic handler (ashx
) instead of an aspx page for your callback url.
回答2:
It seems this question is solved by an answer to another question of mine: How can I create an http response from scratch? .
The solution is to add:
HttpContext.Current.Response.End();
来源:https://stackoverflow.com/questions/11177384/google-checkout-notification-acknowledgment-failing