private static void HandleOrderStateChangeNotification(GCheckout.AutoGen.OrderStateChangeNotification inputOrderStateChangeNotification) { // Charge Order If Chargeable if ((inputOrderStateChangeNotification.previousfinancialorderstate.ToString().Equals("REVIEWING")) && (inputOrderStateChangeNotification.newfinancialorderstate.ToString().Equals("CHARGEABLE"))) { GCheckout.OrderProcessing.ChargeOrderRequest oneChargeOrderRequest = new GCheckout.OrderProcessing.ChargeOrderRequest(inputOrderStateChangeNotification.googleordernumber); GCheckout.Util.GCheckoutResponse oneGCheckoutResponse = oneChargeOrderRequest.Send(); } // Update License If Charged if ((inputOrderStateChangeNotification.previousfinancialorderstate.ToString().Equals("CHARGING")) && (inputOrderStateChangeNotification.newfinancialorderstate.ToString().Equals("CHARGED"))) { // TODO: For each shopping cart item received in the NewOrderNotification, authorize the license } // TODO: Add custom processing for this notification type }
private static void HandleOrderStateChangeNotification(GCheckout.AutoGen.OrderStateChangeNotification notification) { // Charge Order If Chargeable if ((notification.previousfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.REVIEWING) && (notification.newfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGEABLE)) { ChargeOrderRequest oneChargeOrderRequest = new ChargeOrderRequest(notification.googleordernumber); GCheckout.Util.GCheckoutResponse oneGCheckoutResponse = oneChargeOrderRequest.Send(); } // Update License If Charged if ((notification.previousfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGING) && (notification.newfinancialorderstate == GCheckout.AutoGen.FinancialOrderState.CHARGED)) { // TODO: For each shopping cart item received in the NewOrderNotification, authorize the license } // TODO: Add custom processing for this notification type }
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); } } } }
public override void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification) { }
//private GoogleCheckOutSettingInfo GetSettingGooglePayment() //{ // GoogleCheckOutSettingInfo setting = new GoogleCheckOutSettingInfo(); // GoogleCheckOutWCFService ser = new GoogleCheckOutWCFService(); //} public static void ProcessNotification(string serialNumber) { GoogleCheckOutWCFService pw = new GoogleCheckOutWCFService(); List <GoogleCheckOutSettingKeyInfo> sf; sf = pw.GoogleCheckOutSettingKey(); MerchantID = sf[0].GoogleMerchantID; MerchantKey = sf[0].GoogleMerchantKey; Environment = sf[0].GoogleEnvironmentType; GCheckout.OrderProcessing.NotificationHistorySerialNumber sn = new NotificationHistorySerialNumber(serialNumber); GCheckout.OrderProcessing.NotificationHistoryRequest oneNotificationHistoryRequest = new NotificationHistoryRequest(MerchantID, MerchantKey, Environment, sn); //newNotificationHistorySerialNumber(serialNumber) //Response NotificationHistoryResponse oneNotificationHistoryResponse = (NotificationHistoryResponse)oneNotificationHistoryRequest.Send(); //Get type of notification object notification = GCheckout.Util.EncodeHelper.Deserialize(oneNotificationHistoryResponse.ResponseXml); //Check for the notification and call functions according to that if (notification.GetType().Equals(typeof(GCheckout.AutoGen.NewOrderNotification))) { GCheckout.AutoGen.NewOrderNotification oneNewOrderNotification = (GCheckout.AutoGen.NewOrderNotification)notification; if (oneNewOrderNotification.serialnumber.Equals(serialNumber)) { HandleNewOrderNotification(oneNewOrderNotification); } } else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.OrderStateChangeNotification))) { GCheckout.AutoGen.OrderStateChangeNotification oneOrderStateChangeNotification = (GCheckout.AutoGen.OrderStateChangeNotification)notification; if (oneOrderStateChangeNotification.serialnumber.Equals(serialNumber)) { HandleOrderStateChangeNotification(oneOrderStateChangeNotification); } } else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.RiskInformationNotification))) { GCheckout.AutoGen.RiskInformationNotification oneRiskInformationNotification = (GCheckout.AutoGen.RiskInformationNotification)notification; if (oneRiskInformationNotification.serialnumber.Equals(serialNumber)) { HandleRiskInformationNotification(oneRiskInformationNotification); } } else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.AuthorizationAmountNotification))) { GCheckout.AutoGen.AuthorizationAmountNotification oneAuthorizationAmountNotification = (GCheckout.AutoGen.AuthorizationAmountNotification)notification; if (oneAuthorizationAmountNotification.serialnumber.Equals(serialNumber)) { HandleAuthorizationAmountNotification(oneAuthorizationAmountNotification); } } else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.ChargeAmountNotification))) { GCheckout.AutoGen.ChargeAmountNotification oneChargeAmountNotification = (GCheckout.AutoGen.ChargeAmountNotification)notification; if (oneChargeAmountNotification.serialnumber.Equals(serialNumber)) { HandleChargeAmountNotification(oneChargeAmountNotification); } } else { string exceptionText = "Unhandled Type [" + notification.GetType().ToString() + "]!; serialNumber=[" + serialNumber + "];"; throw new ArgumentOutOfRangeException(exceptionText); } }
public abstract void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification);
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(); }
public static void ProcessNotification(string serialNumber) { //The next two statements set up a request and call google checkout for the details based on that serial number. NotificationHistoryRequest oneNotificationHistoryRequest = new NotificationHistoryRequest(new NotificationHistorySerialNumber(serialNumber)); NotificationHistoryResponse oneNotificationHistoryResponse = (NotificationHistoryResponse)oneNotificationHistoryRequest.Send(); // oneNotificationHistoryResponse.ResponseXml contains the complete response //what you need to do now is process the data that was returned. // Iterate through the notification history for this order looking for the notification that exactly matches the given serial number foreach (object oneNotification in oneNotificationHistoryResponse.NotificationResponses) { if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.NewOrderNotification))) { GCheckout.AutoGen.NewOrderNotification oneNewOrderNotification = (GCheckout.AutoGen.NewOrderNotification)oneNotification; if (oneNewOrderNotification.serialnumber.Equals(serialNumber)) { HandleNewOrderNotification(oneNewOrderNotification); } } else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.OrderStateChangeNotification))) { GCheckout.AutoGen.OrderStateChangeNotification oneOrderStateChangeNotification = (GCheckout.AutoGen.OrderStateChangeNotification)oneNotification; if (oneOrderStateChangeNotification.serialnumber.Equals(serialNumber)) { HandleOrderStateChangeNotification(oneOrderStateChangeNotification); } } else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.RiskInformationNotification))) { GCheckout.AutoGen.RiskInformationNotification oneRiskInformationNotification = (GCheckout.AutoGen.RiskInformationNotification)oneNotification; if (oneRiskInformationNotification.serialnumber.Equals(serialNumber)) { HandleRiskInformationNotification(oneRiskInformationNotification); } } else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.AuthorizationAmountNotification))) { GCheckout.AutoGen.AuthorizationAmountNotification oneAuthorizationAmountNotification = (GCheckout.AutoGen.AuthorizationAmountNotification)oneNotification; if (oneAuthorizationAmountNotification.serialnumber.Equals(serialNumber)) { HandleAuthorizationAmountNotification(oneAuthorizationAmountNotification); } } else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.ChargeAmountNotification))) { GCheckout.AutoGen.ChargeAmountNotification oneChargeAmountNotification = (GCheckout.AutoGen.ChargeAmountNotification)oneNotification; if (oneChargeAmountNotification.serialnumber.Equals(serialNumber)) { HandleChargeAmountNotification(oneChargeAmountNotification); } } else { throw new ArgumentOutOfRangeException("Unhandled Type [" + oneNotification.GetType().ToString() + "]!; serialNumber=[" + serialNumber + "];"); } } }