Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CommonLogic.QueryStringCanBeDangerousContent("loadcheck") == "1")
            {
                Response.Write("<loadcheck>" + System.DateTime.Now.ToString() + "</loadcheck>");
            }
            else
            {
                // this callback requires basic authentication
                if (!GoogleCheckout.VerifyMessageAuthentication(Request.Headers["Authorization"]) && !AppLogic.AppConfigBool("GoogleCheckout.UseSandbox"))
                {
                    Response.StatusCode        = 401;
                    Response.StatusDescription = "Access Denied";
                }

                else if (Request.ContentLength > 0)
                {
                    // place notification into string
                    string xmlData = Encoding.UTF8.GetString(Request.BinaryRead(Request.ContentLength));

                    //  Select the appropriate function to handle the notification
                    //  by evaluating the root tag of the document
                    XmlDocument googleResponse = new XmlDocument();
                    googleResponse.LoadXml(xmlData);

                    int MerchantOrderNumber = 0;

                    switch (googleResponse.DocumentElement.Name)
                    {
                    case "merchant-calculation-callback":
                        Response.Write(GoogleCheckout.createMerchantCalculationResults(xmlData));
                        break;

                    case "new-order-notification":
                        sendNotificationAcknowledgment();
                        int ordernumber = GoogleCheckout.processNewOrderNotification(xmlData);
                        GoogleCheckout.AddMerchantOrderNumber(ordernumber);
                        break;

                    case "order-state-change-notification":
                        sendNotificationAcknowledgment();
                        GoogleCheckout.ProcessOrderStateChangeNotification(xmlData);
                        break;

                    case "risk-information-notification":
                        sendNotificationAcknowledgment();
                        MerchantOrderNumber = GoogleCheckout.processRiskInformationNotification(xmlData);
                        break;

                    case "charge-amount-notification":
                        sendNotificationAcknowledgment();
                        GoogleCheckout.processChargeAmountNotification(xmlData);
                        break;

                    case "refund-amount-notification":
                        sendNotificationAcknowledgment();
                        GoogleCheckout.processRefundAmountNotification(xmlData);
                        break;

                    case "chargeback-amount-notification":
                        sendNotificationAcknowledgment();
                        GoogleCheckout.processChargebackAmountNotification(xmlData);
                        break;

                    case "request-received":
                        GoogleCheckout.processRequestReceived(xmlData);
                        break;

                    case "error":
                        GoogleCheckout.processErrorNotification(xmlData);
                        break;

                    case "diagnosis":
                        GoogleCheckout.processDiagnosisNotification(xmlData);
                        break;

                    default:
                        GoogleCheckout.processUnknownNotification(xmlData);
                        break;
                    }
                }
            }
        }