private void PaymentLogUpdateOrderStateChange(OrderStateChangeNotification notification) { string paymentResponse = "order-state-change-notification :: "; paymentResponse += "NewFinancialOrderState :" + notification.newfinancialorderstate.ToString() + ","; paymentResponse += "NewFulFillmentOrderState :" + notification.newfulfillmentorderstate.ToString() + ","; paymentResponse += "PreviousFinancialOrderState :" + notification.previousfinancialorderstate.ToString() + ","; paymentResponse += "PreviousFulFillmentOrderState :" + notification.previousfulfillmentorderstate.ToString() + ","; paymentResponse += "Reason :" + notification.reason + ","; paymentResponse += "SerialNumber :" + notification.serialnumber + ","; paymentResponse += "TimeStamp :" + notification.timestamp.ToString(); Log.Debug("-*************** Check PaymentLog **************-"); Log.Debug("notification.googleordernumber = " + notification.googleordernumber); Log.Debug("paymentResponse = " + paymentResponse); Log.Debug("GetPaymentName = " + GetPaymentName()); string orderID = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(notification.googleordernumber); PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = orderID; paymentLog.PaymentResponse = paymentResponse; paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = String.Empty; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug("-************* End Check PaymentLog ************-"); }
private void SendErrorEmail(OrderStateChangeNotification notification) { string orderID = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(notification.googleordernumber); Order order = DataAccessContext.OrderRepository.GetOne(orderID); WebUtilities.SendMail( NamedConfig.AutoSenderEmail, DataAccessContext.Configurations.GetValue("ErrorLogEmail"), "Failed processing order ID " + order.OrderID, "There is an error while processing this order.\n" + " Shopping Cart Order ID: " + order.OrderID + "\n" + " Google Order ID: " + order.GatewayOrderID + "\n" + " Financial Order State: " + notification.newfinancialorderstate.ToString() + "\n" + " Fulfillment Order State: " + notification.newfulfillmentorderstate.ToString() + "\n" + "\nPlease verify this order in your Google Checkout Merchant account.\n"); }
private static void ProcessNotification(string Type, string Xml) { switch (Type) { case "new-order-notification": NewOrderNotification N1 = (NewOrderNotification) EncodeHelper.Deserialize(Xml, typeof(NewOrderNotification)); // Add call to existing business system here, passing data from N1. break; case "risk-information-notification": RiskInformationNotification N2 = (RiskInformationNotification) EncodeHelper.Deserialize(Xml, typeof(RiskInformationNotification)); // Add call to existing business system here, passing data from N2. break; case "order-state-change-notification": OrderStateChangeNotification N3 = (OrderStateChangeNotification) EncodeHelper.Deserialize(Xml, typeof(OrderStateChangeNotification)); // Add call to existing business system here, passing data from N3. break; case "charge-amount-notification": ChargeAmountNotification N4 = (ChargeAmountNotification) EncodeHelper.Deserialize(Xml, typeof(ChargeAmountNotification)); // Add call to existing business system here, passing data from N4. break; case "refund-amount-notification": RefundAmountNotification N5 = (RefundAmountNotification) EncodeHelper.Deserialize(Xml, typeof(RefundAmountNotification)); // Add call to existing business system here, passing data from N5. break; case "chargeback-amount-notification": ChargebackAmountNotification N6 = (ChargebackAmountNotification) EncodeHelper.Deserialize(Xml, typeof(ChargebackAmountNotification)); // Add call to existing business system here, passing data from N6. break; default: throw new ApplicationException("Unknown notification type: " + Type); } }
private void HandleOrderStateChangeNotification(OrderStateChangeNotification notification) { NotificationSerialNumber = notification.serialnumber; string providerName = GoogleCheckoutLog.GetProviderNameFromOrderNumber(notification.googleordernumber); if (providerName.Length > 0) { GCheckoutNotificationHandlerProvider provider = GCheckoutNotificationManager.Providers[providerName]; if (provider != null) { provider.HandleOrderStateChangeNotification(RequestXml, notification); return; } } // if no provider found just log it log.Info("No GCheckoutNotification Provider found for google order " + notification.googleordernumber + " so just logging it"); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.SiteGuid = siteSettings.SiteGuid; gLog.RawResponse = RequestXml; gLog.NotificationType = "OrderStateChangeNotification"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.FinanceState = notification.newfinancialorderstate.ToString(); gLog.FullfillState = notification.newfulfillmentorderstate.ToString(); gLog.GTimestamp = notification.timestamp; gLog.AvsResponse = notification.reason; gLog.CartGuid = orderGuid; gLog.Save(); }
private void processOrderStateChangeNotification(string xmlData) { try { OrderStateChangeNotification changeOrder = (OrderStateChangeNotification)EncodeHelper.Deserialize(xmlData, typeof(OrderStateChangeNotification)); FinancialOrderState orderState = changeOrder.newfinancialorderstate; Order order = getMerchantOrderByGoogleOrderID(changeOrder.googleordernumber); if (order != null) { string message = string.Format("Order status {0} from Google: Order Number {1}", orderState, changeOrder.googleordernumber); logMessage(message); OrderManager.InsertOrderNote(order.OrderId, message, false, DateTime.Now); if (orderState == FinancialOrderState.CHARGING || orderState == FinancialOrderState.REVIEWING) { } if (orderState == FinancialOrderState.CHARGEABLE) { order = OrderManager.MarkAsAuthorized(order.OrderId); } if (orderState == FinancialOrderState.CHARGED) { order = OrderManager.MarkOrderAsPaid(order.OrderId); } if (orderState == FinancialOrderState.CANCELLED || orderState == FinancialOrderState.CANCELLED_BY_GOOGLE) { order = OrderManager.CancelOrder(order.OrderId, true); } } } catch (Exception exc) { logMessage("processOrderStateChangeNotification Exception: " + exc.Message + ": " + exc.StackTrace); } }
/// <summary> /// Processes the notification. /// </summary> /// <param name="xmlFile">The XML file.</param> /// <returns>Serial number of the notification</returns> public static string ProcessNotification(string xmlFile) { string conn = GetConnectionString(); StoreDataClassesDataContext db = new StoreDataClassesDataContext(conn); string SerialNumber = ""; //Read XML file StreamReader strReader = new StreamReader(xmlFile); string requestedXml = strReader.ReadToEnd(); //Act on XML file switch (EncodeHelper.GetTopElement(requestedXml)) { case "new-order-notification": NewOrderNotification N1 = (NewOrderNotification)EncodeHelper.Deserialize(requestedXml, typeof(NewOrderNotification)); ///This notification tells us that Google has accepted the order SerialNumber = N1.serialnumber; Int64 OrderNumber1 = Int64.Parse(N1.googleordernumber); int pos = N1.buyershippingaddress.contactname.IndexOf(" "); string ShipToFirstName = N1.buyershippingaddress.contactname.Substring(0, pos); string ShipToLatsName = N1.buyershippingaddress.contactname.Substring(pos + 1); string UserName = N1.shoppingcart.merchantprivatedata.Any[1].InnerText; int internalOrderId = int.Parse(EncodeHelper.GetElementValue(requestedXml, "MERCHANT_DATA_HIDDEN")); order newOrder = db.orders.Where(o => o.order_id == internalOrderId).Single <order>(); newOrder.google_order_number = OrderNumber1; newOrder.order_date = N1.timestamp; newOrder.order_by = UserName; newOrder.sub_total = N1.ordertotal.Value; newOrder.total = N1.ordertotal.Value; newOrder.charged_amount = 0; newOrder.status = "NEW"; newOrder.root_id = 1; //newOrder.shipping_first_name = ShipToFirstName; //newOrder.shipping_last_name = ShipToLatsName; //newOrder.shipping_address = N1.buyershippingaddress.address1; //newOrder.shipping_city = N1.buyershippingaddress.city; //newOrder.shipping_state = N1.buyershippingaddress.region; //newOrder.shipping_zip = N1.buyershippingaddress.postalcode; //newOrder.shipping_country = N1.buyerbillingaddress.countrycode; db.SubmitChanges(); db.orders.DeleteAllOnSubmit(db.orders.Where(o => (o.status == "TEMP" && o.order_by == UserName))); db.SubmitChanges(); foreach (Item ThisItem in N1.shoppingcart.items) { int itemId = int.Parse(ThisItem.merchantprivateitemdata.Any[0].InnerText); string desc = ThisItem.itemdescription; int quantity = ThisItem.quantity; decimal price = ThisItem.unitprice.Value; bool tangible = false; if (ThisItem.digitalcontent != null) { tangible = true; } order_item newItem = new order_item(); newItem.item_id = itemId; newItem.order_id = internalOrderId; newItem.price = price; newItem.qty = quantity; newItem.tangible = tangible; newItem.item_desc = desc; newItem.item_name = ThisItem.itemname; db.order_items.InsertOnSubmit(newItem); db.SubmitChanges(); } break; case "risk-information-notification": RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize(requestedXml, typeof(RiskInformationNotification)); // This notification tells us that Google has authorized the order and it has passed the fraud check SerialNumber = N2.serialnumber; long googleOrderNumber = Int64.Parse(N2.googleordernumber); string contactName = EncodeHelper.GetElementValue(requestedXml, "contact-name"); string email = EncodeHelper.GetElementValue(requestedXml, "email"); string city = EncodeHelper.GetElementValue(requestedXml, "city"); int zip = int.Parse(EncodeHelper.GetElementValue(requestedXml, "postal-code")); string country = EncodeHelper.GetElementValue(requestedXml, "country-code"); bool elibible = N2.riskinformation.eligibleforprotection; char cvn = char.Parse(N2.riskinformation.cvnresponse); if (elibible && N2.riskinformation.cvnresponse == "M") { customer newCustomer = new customer(); newCustomer.google_order_number = googleOrderNumber; newCustomer.eligibility = elibible; newCustomer.contact_name = contactName; newCustomer.email = email; newCustomer.address = N2.riskinformation.billingaddress.address1; newCustomer.city = city; newCustomer.zip = zip; newCustomer.country = country; newCustomer.avs = char.Parse(N2.riskinformation.avsresponse); newCustomer.cvn = cvn; newCustomer.cc_number = int.Parse(N2.riskinformation.partialccnumber); newCustomer.ip = N2.riskinformation.ipaddress; db.customers.InsertOnSubmit(newCustomer); db.SubmitChanges(); } else { string reason = "You did not pass Google security check!"; string comment = "Please visis http://checkout.google.com/support/sell/bin/topic.py?topic=15055 for more information"; GCheckout.OrderProcessing.CancelOrderRequest cancelReq = new GCheckout.OrderProcessing.CancelOrderRequest(N2.googleordernumber, reason, comment); cancelReq.Send(); } break; case "order-state-change-notification": OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize(requestedXml, typeof(OrderStateChangeNotification)); // The order has changed either financial or fulfillment state in Google's system. SerialNumber = N3.serialnumber; long googleOrderNumber1 = Int64.Parse(N3.googleordernumber); string newFinanceState = N3.newfinancialorderstate.ToString(); string newFulfillmentState = N3.newfulfillmentorderstate.ToString(); string prevFinanceState = N3.previousfinancialorderstate.ToString(); string prevFulfillmentState = N3.previousfulfillmentorderstate.ToString(); order thisOrder1 = (from or in db.orders where or.google_order_number == googleOrderNumber1 select or).Single <order>(); //if (newFinanceState == "CHARGEABLE") //{ // GCheckout.OrderProcessing.ChargeOrderRequest chargeReq = new GCheckout.OrderProcessing.ChargeOrderRequest(N3.googleordernumber); // chargeReq.Send(); //} thisOrder1.status = newFinanceState; if (newFulfillmentState == "WILL_NOT_DELIVER") { thisOrder1.shipping_status = "CANCELLED"; } else { thisOrder1.shipping_status = newFulfillmentState; } db.SubmitChanges(); break; case "charge-amount-notification": ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(ChargeAmountNotification)); // Google has successfully charged the customer's credit card. SerialNumber = N4.serialnumber; long googleOrderNumber2 = Int64.Parse(N4.googleordernumber); decimal chargedAmount = N4.latestchargeamount.Value; order thisOrder2 = (from or in db.orders where or.google_order_number == googleOrderNumber2 select or).Single <order>(); thisOrder2.charged_amount += chargedAmount; thisOrder2.sub_total -= chargedAmount; db.SubmitChanges(); break; case "refund-amount-notification": RefundAmountNotification N5 = (RefundAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(RefundAmountNotification)); // Google has successfully refunded the customer's credit card. SerialNumber = N5.serialnumber; long googleOrderNumber3 = Int64.Parse(N5.googleordernumber); decimal refundedAmount = N5.latestrefundamount.Value; order thisOrder3 = (from or in db.orders where or.google_order_number == googleOrderNumber3 select or).Single <order>(); thisOrder3.status = "REFUNDED"; thisOrder3.charged_amount -= refundedAmount; db.SubmitChanges(); break; case "chargeback-amount-notification": ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(ChargebackAmountNotification)); // A customer initiated a chargeback with his credit card company to get her money back. SerialNumber = N6.serialnumber; long googleOrderNumber4 = Int64.Parse(N6.googleordernumber); decimal chargebackAmount = N6.latestchargebackamount.Value; order thisOrder4 = (from or in db.orders where or.google_order_number == googleOrderNumber4 select or).Single <order>(); thisOrder4.status = "CHARGEBACK"; db.SubmitChanges(); break; default: break; } strReader.Close(); strReader.Dispose(); return(SerialNumber); }
public OrderStateChangeHandler(OrderStateChangeNotification n1) { N1 = n1; }
private void HandleNotification() { if (requestContext == null) { return; } Stream RequestStream = requestContext.Request.InputStream; StreamReader RequestStreamReader = new StreamReader(RequestStream); RequestXml = RequestStreamReader.ReadToEnd(); RequestStream.Close(); if (RequestXml.Length == 0) { return; } try { object requestObject = EncodeHelper.Deserialize(RequestXml); if (requestObject is NewOrderNotificationExtended) { NewOrderNotificationExtended n1 = requestObject as NewOrderNotificationExtended; HandleNewOrderNotificationExtended(n1); return; } if (requestObject is GCheckout.AutoGen.RiskInformationNotification) { RiskInformationNotification n2 = requestObject as RiskInformationNotification; HandleRiskInformationNotification(n2); return; } if (requestObject is GCheckout.AutoGen.ChargeAmountNotification) { ChargeAmountNotification n3 = requestObject as ChargeAmountNotification; HandleChargeAmountNotification(n3); return; } if (requestObject is GCheckout.AutoGen.ChargebackAmountNotification) { ChargebackAmountNotification n4 = requestObject as ChargebackAmountNotification; HandleChargebackAmountNotification(n4); return; } if (requestObject is GCheckout.AutoGen.AuthorizationAmountNotification) { AuthorizationAmountNotification n5 = requestObject as AuthorizationAmountNotification; HandleAuthorizationAmountNotification(n5); return; } if (requestObject is GCheckout.AutoGen.RefundAmountNotification) { RefundAmountNotification n6 = requestObject as RefundAmountNotification; HandleRefundAmountNotification(n6); return; } if (requestObject is OrderStateChangeNotification) { OrderStateChangeNotification n7 = requestObject as OrderStateChangeNotification; HandleOrderStateChangeNotification(n7); return; } } catch (Exception ex) { log.Error(ex); log.Error(RequestXml); // after testing there me be some invalid posts from google // for deleted orders or carts. They'll keep sending them for 30 days // or until they get a 200 ok response // so this option is to allow clearing those without wating 30 days // other than during development this should be false bool alwaysSendNormalResponse = ConfigHelper.GetBoolProperty("GCheckoutForceNormalResponse", false); if (!alwaysSendNormalResponse) { throw (ex); } } // probably some hacking or random traffic if we reach here but log it //log.Error(RequestXml); log.Info("google notification: " + RequestXml); }
public abstract void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification);
public override void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification) { }
public override void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); gLog.RawResponse = requestXml; gLog.NotificationType = "OrderStateChangeNotification"; gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.FinanceState = notification.newfinancialorderstate.ToString(); gLog.FullfillState = notification.newfulfillmentorderstate.ToString(); gLog.GTimestamp = notification.timestamp; gLog.AvsResponse = notification.reason; gLog.CartGuid = orderGuid; gLog.Save(); if (orderGuid == Guid.Empty) { return; } Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) { return; } Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) { return; } gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); if (notification.newfinancialorderstate == FinancialOrderState.CHARGED) { order.StatusGuid = OrderStatus.OrderStatusFulfillableGuid; order.Save(); if (!order.HasShippingProducts()) { // order only has download products so tell google the order is fulfilled try { CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); string gEvironment; if (commerceConfig.GoogleEnvironment == GCheckout.EnvironmentType.Sandbox) { gEvironment = "Sandbox"; } else { gEvironment = "Production"; } GCheckout.OrderProcessing.DeliverOrderRequest fulfillNotification = new GCheckout.OrderProcessing.DeliverOrderRequest( commerceConfig.GoogleMerchantID, commerceConfig.GoogleMerchantKey, gEvironment, notification.googleordernumber); fulfillNotification.Send(); StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); log.Info("Sent DeliverOrderRequest to google api for google order " + notification.googleordernumber); } catch (Exception ex) { log.Error(ex); } } } }
protected void Page_Load(object sender, EventArgs e) { // Extract the XML from the request. Stream RequestStream = Request.InputStream; StreamReader RequestStreamReader = new StreamReader(RequestStream); string RequestXml = RequestStreamReader.ReadToEnd(); RequestStream.Close(); Log.Debug("Request XML:\n" + RequestXml); string gatewayOrderID = ""; string orderID; OrderNotifyService orderBusiness; try { // Act on the XML. switch (EncodeHelper.GetTopElement(RequestXml)) { case "new-order-notification": Log.Debug("Start new-order-notification"); NewOrderNotification N1 = (NewOrderNotification)EncodeHelper.Deserialize(RequestXml, typeof(NewOrderNotification)); string OrderNumber1 = N1.googleordernumber; PaymentLogUpdateNewOrderNotification(N1); _serialNumber = N1.serialnumber; Log.Debug("-********************- Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-"); Log.Debug("GetOrderIDByGateWayID ( " + OrderNumber1 + " ) = " + DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1)); Log.Debug("-********************- END Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-"); if (DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1) == "0") { BuildShoppingCart(RequestXml, N1); Log.Debug("Start converting to order"); OrderCreateService orderCreateService = new OrderCreateService( StoreContext.ShoppingCart, StoreContext.CheckoutDetails, StoreContext.Culture, StoreContext.Currency, AffiliateHelper.GetAffiliateCode(), WebUtilities.GetVisitorIP()); string storeID = EncodeHelper.GetElementValue(RequestXml, "StoreID"); DataAccessContext.SetStoreRetriever(new StoreRetriever(storeID)); OrderAmount orderAmount = orderCreateService.GetOrderAmount(Customer.Null) .Add(CartItemPromotion.CalculatePromotionShippingAndTax( StoreContext.CheckoutDetails, StoreContext.ShoppingCart.SeparateCartItemGroups(), Customer.Null)); Order order = orderCreateService.PlaceOrderAnonymous(orderAmount, SystemConst.UnknownUser, CreateBuyerBillingAddress(N1), ConvertToString(N1.buyerbillingaddress.email), DataAccessContext.StoreRetriever, StoreContext.Culture); AffiliateOrder affiliateorder = new AffiliateOrder(); affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode(); affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount); orderBusiness = new OrderNotifyService(order.OrderID); Log.Debug("End converting to order"); Log.Debug("Start sending order email"); orderBusiness.SendOrderEmail(); Log.Debug("End sending order email"); Order orderDetail = DataAccessContext.OrderRepository.GetOne(order.OrderID); orderDetail.GatewayOrderID = OrderNumber1; Log.Debug("OrderDetail.GatewayOrderID = " + OrderNumber1); Log.Debug("Start Save Order Detail"); DataAccessContext.OrderRepository.Save(orderDetail); Log.Debug("End Save Order Detail"); DataAccessContext.SetStoreRetriever(new StoreRetriever()); } else { Order orderDetail = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1)); Log.Debug("-**************************- start Check Error -**************************-"); Log.Debug("N1.googleOrderNumber = " + N1.googleordernumber); Log.Debug("OrderNumber1 = " + OrderNumber1); Log.Debug("N1.buyerbillingaddress.contactname = " + ConvertToString(N1.buyerbillingaddress.contactname)); Log.Debug("N1.buyerbillingaddress.address1 = " + ConvertToString(N1.buyerbillingaddress.address1)); Log.Debug("N1.buyerbillingaddress.city = " + ConvertToString(N1.buyerbillingaddress.city)); Log.Debug("N1.buyerbillingaddress.region = " + ConvertToString(N1.buyerbillingaddress.contactname)); Log.Debug("N1.buyerbillingaddress.postalcode = " + ConvertToString(N1.buyerbillingaddress.postalcode)); Log.Debug("orderDetail.Billing.Company = " + orderDetail.Billing.Company); Log.Debug("orderDetail.Billing.Country = " + orderDetail.Billing.Country); Log.Debug("orderDetail.Billing.Phone = " + orderDetail.Billing.Phone); Log.Debug("orderDetail.Billing.Fax = " + orderDetail.Billing.Fax); Log.Debug("-**************************- End Check Error -**************************-"); orderDetail.Billing = new Vevo.Base.Domain.Address(ConvertToString(N1.buyerbillingaddress.contactname), String.Empty, orderDetail.Billing.Company, ConvertToString(N1.buyerbillingaddress.address1), ConvertToString(N1.buyerbillingaddress.address2), ConvertToString(N1.buyerbillingaddress.city), ConvertToString(N1.buyerbillingaddress.region), ConvertToString(N1.buyerbillingaddress.postalcode), orderDetail.Billing.Country, orderDetail.Billing.Phone, orderDetail.Billing.Fax); orderDetail.Email = ConvertToString(N1.buyerbillingaddress.email); DataAccessContext.OrderRepository.Save(orderDetail); } Log.Debug("End new-order-notification"); break; case "risk-information-notification": Log.Debug("risk-information-notification"); RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize( RequestXml, typeof(RiskInformationNotification)); // This notification tells us that Google has authorized the order // and it has passed the fraud check. // Use the data below to determine if you want to accept the order, then start processing it. gatewayOrderID = N2.googleordernumber; _serialNumber = N2.serialnumber; PaymentLogUpdateRiskInformation(N2); VerifyAvsAndCvv(N2); break; case "order-state-change-notification": Log.Debug("Start order-state-change-notification"); OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize( RequestXml, typeof(OrderStateChangeNotification)); _serialNumber = N3.serialnumber; PaymentLogUpdateOrderStateChange(N3); if (N3.newfinancialorderstate != N3.previousfinancialorderstate) { Order orderDetail = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(N3.googleordernumber)); orderDetail.GatewayPaymentStatus = N3.newfinancialorderstate.ToString(); DataAccessContext.OrderRepository.Save(orderDetail); switch (N3.newfinancialorderstate) { case FinancialOrderState.PAYMENT_DECLINED: case FinancialOrderState.CANCELLED_BY_GOOGLE: SendErrorEmail(N3); break; case FinancialOrderState.CHARGEABLE: if (DataAccessContext.Configurations.GetBoolValueNoThrow("GCheckoutChargeAuto")) { GoogleChargeOrder(N3.googleordernumber); } break; } } Log.Debug("End order-state-change-notification"); break; case "charge-amount-notification": Log.Debug("Start charge-amount-notification"); ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(RequestXml, typeof(ChargeAmountNotification)); // Google has successfully charged the customer's credit card. gatewayOrderID = N4.googleordernumber; _serialNumber = N4.serialnumber; PaymentLogChargeAmountUpdate(N4); orderID = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID); orderBusiness = new OrderNotifyService(orderID); orderBusiness.ProcessPaymentComplete(); Log.Debug("End charge-amount-notification"); break; case "refund-amount-notification": Log.Debug("Start refund-amount-notification"); RefundAmountNotification N5 = (RefundAmountNotification)EncodeHelper.Deserialize( RequestXml, typeof(RefundAmountNotification)); // Google has successfully refunded the customer's credit card. gatewayOrderID = N5.googleordernumber; _serialNumber = N5.serialnumber; //decimal RefundedAmount = N5.latestrefundamount.Value; PaymentLogUpdateRefundAmount(N5); Order orderDetails = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID)); orderDetails.PaymentComplete = false; DataAccessContext.OrderRepository.Save(orderDetails); Log.Debug("End refund-amount-notification"); break; case "chargeback-amount-notification": Log.Debug("Start chargeback-amount-notification"); ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize( RequestXml, typeof(ChargebackAmountNotification)); // A customer initiated a chargeback with his credit card company to get her money back. gatewayOrderID = N6.googleordernumber; _serialNumber = N6.serialnumber; decimal ChargebackAmount = N6.latestchargebackamount.Value; PaymentLogUpdateChargeback(N6); orderDetails = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID)); orderDetails.GatewayPaymentStatus = "ChargeBack"; DataAccessContext.OrderRepository.Save(orderDetails); Log.Debug("End chargeback-amount-notification"); break; default: break; } } catch (Exception ex) { DataAccessContext.SetStoreRetriever(new StoreRetriever()); Log.Debug(ex.ToString()); } }