Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string serialNumber = null;

        // Receive Request
        Stream requestInputStream = Request.InputStream;

        string requestStreamAsString = null;

        using (System.IO.StreamReader oneStreamReader = new StreamReader(requestInputStream)) {
            requestStreamAsString = oneStreamReader.ReadToEnd();
        }

        // Parse Request to retreive serial number
        string[] requestStreamAsParts = requestStreamAsString.Split(new char[] { '=' });
        if (requestStreamAsParts.Length >= 2)
        {
            serialNumber = requestStreamAsParts[1];
        }

        // Call NotificationHistory Google Checkout API to retrieve the notification for the given serial number and process the notification
        GoogleCheckoutHelper.ProcessNotification(serialNumber);

        //serialize the message to the output stream only if you could process the message.
        //Otherwise throw an http 500.

        var response = new GCheckout.AutoGen.NotificationAcknowledgment();

        response.serialnumber = serialNumber;

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.BinaryWrite(GCheckout.Util.EncodeHelper.Serialize(response));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                //StreamWriter ss = new StreamWriter(Server.MapPath("~/POST.txt"));
                //ss.WriteLine("POST");
                //ss.WriteLine("Total=" + Request.Form.Count);

                //foreach (var formvalue in Request.Form)
                //{
                //    ss.Write(formvalue);
                //    ss.Write("=");
                //    ss.WriteLine(Request.Form[formvalue.ToString()]);

                //}

                //ss.Close();

                string serialNumber = string.Empty;;
                // Receive Request
                Stream requestInputStream    = Request.InputStream;
                string requestStreamAsString = string.Empty;;
                using (System.IO.StreamReader streamReader = new StreamReader(requestInputStream))
                {
                    requestStreamAsString = streamReader.ReadToEnd();
                }
                // Parse Request to retrieve serial number
                string[] requestStreamAsParts = requestStreamAsString.Split(new char[] { '=' });
                if (requestStreamAsParts.Length >= 2)
                {
                    serialNumber = requestStreamAsParts[1];
                }


                if (!string.IsNullOrEmpty(serialNumber))
                {
                    bool isSerialNumber = GoogleCheckOutHandler.SerialNumberExist(serialNumber.Substring(0, 15));
                    if (!isSerialNumber)
                    {
                        // Call NotificationHistory Google Checkout API to retrieve the notification for the given serial number and process the notification(This class will be created in next step)
                        GoogleCheckoutHelper.ProcessNotification(serialNumber);
                        //serialize the message to the output stream only if you could process the message.

                        //Send Google Notification Acknowledgement
                        var 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;
                    }
                }
            }
            catch (Exception ex)
            { ProcessException(ex); }
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            //GCheckoutButton1 = new GCheckoutButton();

            //CheckoutShoppingCartRequest Req = GCheckoutButton1.CreateRequest();
            //Req.AddItem("Snickers", "Packed with peanuts.", 0.75m, 2);
            //GCheckout.Util.GCheckoutResponse Resp = Req.Send();
            //Response.Redirect(Resp.RedirectUrl, true);

            //GCheckout.Util.GCheckoutResponse responce = histroey.Send();

            //GCheckout.Checkout.CheckoutShoppingCartRequest sad = new GCheckout.Checkout.CheckoutShoppingCartRequest("417255259260942", "LzWjnZDmrxRiA0UlIUfeSg", GCheckout.EnvironmentType.Sandbox, "GBP", 10, false);

              GCheckout.Checkout.CheckoutShoppingCartRequest CheckoutShoppingCartRequest = new GCheckout.Checkout.CheckoutShoppingCartRequest("417255259260942", "LzWjnZDmrxRiA0UlIUfeSg", GCheckout.EnvironmentType.Sandbox, "GBP", 10, false);

              GCheckout.Checkout.ShoppingCartItem ShoppingCartItem = new GCheckout.Checkout.ShoppingCartItem();

              ShoppingCartItem.Description = "itsm one DEsc";

              ShoppingCartItem.Name = "item 01 ";
              ShoppingCartItem.Price = Convert.ToDecimal("10.00");
              ShoppingCartItem.Quantity = 1;
              ShoppingCartItem.MerchantPrivateItemData = "<Orderid>10</Orderid>";

              CheckoutShoppingCartRequest.AddItem(ShoppingCartItem);

              GCheckout.Util.GCheckoutResponse Resp = CheckoutShoppingCartRequest.Send();
              Response.Redirect(Resp.RedirectUrl,true);

            //https://417255259260942:[email protected]/checkout/api/checkout/v2/requestForm/Merchant/417255259260942

              string serial = Request["serial-number"];

              // do my stuff

              var ack = new GCheckout.AutoGen.NotificationAcknowledgment();
              ack.serialnumber = serial;

              StringBuilder stb = new StringBuilder();
              stb.Append(GCheckout.Util.EncodeHelper.Serialize(ack));

            //          Response.BinaryWrite(GCheckout.Util.EncodeHelper.Serialize(ack));
              ///        Response.StatusCode = 200;
        }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                string serialNumber          = string.Empty;;
                Stream requestInputStream    = Request.InputStream;
                string requestStreamAsString = string.Empty;;
                using (System.IO.StreamReader streamReader = new StreamReader(requestInputStream))
                {
                    requestStreamAsString = streamReader.ReadToEnd();
                }
                string[] requestStreamAsParts = requestStreamAsString.Split(new char[] { '=' });
                if (requestStreamAsParts.Length >= 2)
                {
                    serialNumber = requestStreamAsParts[1];
                }


                if (!string.IsNullOrEmpty(serialNumber))
                {
                    bool isSerialNumber = GoogleCheckOutHandler.SerialNumberExist(serialNumber.Substring(0, 15));
                    if (!isSerialNumber)
                    {
                        GoogleCheckoutHelper.ProcessNotification(serialNumber);

                        var 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;
                    }
                }
            }
            catch (Exception ex)
            { ProcessException(ex); }
        }
    }