public static void ParseIPN(int orderID, string transID, string status, int storeID, int portalID, string userName, int customerID, string sessionCode) { GoogleCheckOutHandler ph = new GoogleCheckOutHandler(); try { OrderDetailsCollection ot = new OrderDetailsCollection(); OrderDetailsInfo odinfo = new OrderDetailsInfo(); CartManageSQLProvider cms = new CartManageSQLProvider(); CommonInfo cf = new CommonInfo(); cf.StoreID = storeID; cf.PortalID = portalID; cf.AddedBy = userName; // UpdateOrderDetails AspxOrderDetails objad = new AspxOrderDetails(); SQLHandler sqlH = new SQLHandler(); // use split to split array we already have using "=" as delimiter // WcfSession ws = new WcfSession(); odinfo.OrderID = orderID;//ws.GetSessionVariable("OrderID"); odinfo.ResponseReasonText = status; odinfo.TransactionID = transID; ot.ObjOrderDetails = odinfo; ot.ObjCommonInfo = cf; odinfo.OrderStatusID = 8; objad.UpdateOrderDetails(ot); // UpdateItemQuantity } catch (Exception ex) { throw ex; } }
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) { 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); } } }
private static void HandleNewOrderNotification(GCheckout.AutoGen.NewOrderNotification inputNewOrderNotification) { try { if (inputNewOrderNotification.shoppingcart.merchantprivatedata != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any.Length > 0) { //Retrieve data from MerchantPrivateData GCheckout.AutoGen.anyMultiple oneAnyMultiple = inputNewOrderNotification.shoppingcart.merchantprivatedata; System.Xml.XmlNode[] oneXmlNodeArray = oneAnyMultiple.Any; foreach (XmlNode xn in oneXmlNodeArray) { if (xn.Name == "OrderID") { orderID = Int32.Parse(xn.InnerText.ToString()); } if (xn.Name == "userName") { userName = xn.InnerText.ToString(); } if (xn.Name == "amount") { totalAmount = decimal.Parse(xn.InnerText.ToString()); } if (xn.Name == "selectedCurrency") { selectedCurrency = xn.InnerText.ToString(); } if (xn.Name == "portalID") { portalID = int.Parse(xn.InnerText.ToString()); } if (xn.Name == "customerID") { customerID = int.Parse(xn.InnerText.ToString()); } if (xn.Name == "itemIds") { itemIds = xn.InnerText.ToString(); } if (xn.Name == "storeID") { storeID = int.Parse(xn.InnerText.ToString()); } if (xn.Name == "couponCode") { couponCode = xn.InnerText.ToString(); } if (xn.Name == "sessionCode") { sessionCode = xn.InnerText.ToString(); } if (xn.Name == "pgID") { pgID = int.Parse(xn.InnerText.ToString()); } if (xn.Name == "MerchantID") { MerchantID = xn.InnerText.ToString(); } if (xn.Name == "MerchantKey") { MerchantID = xn.InnerText.ToString(); } } paymentStatus = GCNotificationStatus.Succeeded.ToString(); transID = inputNewOrderNotification.googleordernumber; if (paymentStatus == "Succeeded") { TransactionLogInfo tinfo = new TransactionLogInfo(); TransactionLog Tlog = new TransactionLog(); OrderDetailsCollection odc = new OrderDetailsCollection(); tinfo.ResponseReasonText = "Succeeded"; tinfo.OrderID = orderID; tinfo.StoreID = storeID; tinfo.PortalID = portalID; tinfo.AddedBy = userName; tinfo.CustomerID = customerID; tinfo.SessionCode = sessionCode; tinfo.PaymentGatewayID = pgID; tinfo.PaymentStatus = paymentStatus; tinfo.PayerEmail = ""; tinfo.CreditCard = ""; tinfo.TotalAmount = totalAmount; tinfo.TransactionID = transID; tinfo.RecieverEmail = ""; tinfo.CurrencyCode = selectedCurrency; Tlog.SaveTransactionLog(tinfo); GoogleCheckOutHandler.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode); GoogleCheckOutHandler.UpdateItemQuantity(itemIds, couponCode, storeID, portalID, userName); CartManageSQLProvider cms = new CartManageSQLProvider(); AspxCommonInfo aspxCommonObj = new AspxCommonInfo(); aspxCommonObj.CustomerID = customerID; aspxCommonObj.SessionCode = sessionCode; aspxCommonObj.StoreID = storeID; aspxCommonObj.PortalID = portalID; aspxCommonObj.CultureName = null; aspxCommonObj.UserName = null; cms.ClearCartAfterPayment(aspxCommonObj); } } } catch (Exception ex) { throw ex; } // TODO: Process the MerchantPrivateData if provided foreach (GCheckout.AutoGen.Item oneItem in inputNewOrderNotification.shoppingcart.items) { // TODO: Get MerchantItemId from shopping cart item (oneItem.merchantitemid) and process it } // TODO: Add custom processing for this notification type }