示例#1
0
        private void HandleNewOrderNotificationExtended(NewOrderNotificationExtended newOrder)
        {
            NotificationSerialNumber = newOrder.serialnumber;

            string       merchantDataString = GetMerchantData(newOrder.shoppingcart.merchantprivatedata.Any);
            MerchantData merchantData       = DeserializeMerchantData(merchantDataString);

            if (merchantData != null)
            {
                GCheckoutNotificationHandlerProvider provider
                    = GCheckoutNotificationManager.Providers[merchantData.ProviderName];

                if (provider != null)
                {
                    provider.HandleNewOrderNotificationExtended(RequestXml, newOrder, merchantData);

                    return;
                }
            }


            // if no providers found just log it
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            GoogleCheckoutLog gLog = new GoogleCheckoutLog();

            gLog.SiteGuid         = siteSettings.SiteGuid;
            gLog.RawResponse      = RequestXml;
            gLog.NotificationType = "NewOrderNotification";
            gLog.SerialNumber     = newOrder.serialnumber;
            gLog.OrderNumber      = newOrder.googleordernumber;
            gLog.OrderTotal       = newOrder.ordertotal.Value;
            gLog.BuyerId          = newOrder.buyerid.ToString(CultureInfo.InvariantCulture);
            gLog.FullfillState    = newOrder.fulfillmentorderstate.ToString();
            gLog.FinanceState     = newOrder.financialorderstate.ToString();
            gLog.ShippingTotal    = newOrder.ShippingCost;
            gLog.TaxTotal         = newOrder.orderadjustment.totaltax.Value;
            //gLog.DiscountTotal = ext.orderadjustment.adjustmenttotal.Value;
            gLog.EmailListOptIn = newOrder.buyermarketingpreferences.emailallowed;
            gLog.GTimestamp     = newOrder.timestamp;
            gLog.CartXml        = merchantDataString;
            gLog.Save();
        }
示例#2
0
        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);
        }
示例#3
0
 public override void HandleNewOrderNotificationExtended(
     string requestXml,
     NewOrderNotificationExtended newOrder,
     MerchantData merchantData)
 {
 }
示例#4
0
        //public abstract void RebuildIndex(
        //    PageSettings pageSettings,
        //    string indexPath);

        public abstract void HandleNewOrderNotificationExtended(
            string requestXml,
            NewOrderNotificationExtended newOrder,
            MerchantData merchantData);
        public override void HandleNewOrderNotificationExtended(
            string requestXml,
            NewOrderNotificationExtended newOrder,
            MerchantData merchantData)
        {
            //NotificationSerialNumber = newOrder.serialnumber;


            GoogleCheckoutLog gLog = new GoogleCheckoutLog();

            gLog.ProviderName     = "WebStoreGCheckoutNotificationHandlerProvider";
            gLog.RawResponse      = requestXml;
            gLog.NotificationType = "NewOrderNotification";
            gLog.SerialNumber     = newOrder.serialnumber;
            gLog.OrderNumber      = newOrder.googleordernumber;
            gLog.OrderTotal       = newOrder.ordertotal.Value;
            gLog.BuyerId          = newOrder.buyerid.ToString(CultureInfo.InvariantCulture);
            gLog.FullfillState    = newOrder.fulfillmentorderstate.ToString();
            gLog.FinanceState     = newOrder.financialorderstate.ToString();
            gLog.ShippingTotal    = newOrder.ShippingCost;
            gLog.TaxTotal         = newOrder.orderadjustment.totaltax.Value;
            //gLog.DiscountTotal = ext.orderadjustment.adjustmenttotal.Value;
            gLog.EmailListOptIn = newOrder.buyermarketingpreferences.emailallowed;
            gLog.GTimestamp     = newOrder.timestamp;
            gLog.CartXml        = SerializationHelper.RestoreXmlDeclaration(merchantData.SerializedObject);
            gLog.Save();


            Cart gCart = DeserializeCart(merchantData);

            Guid cartGuid = Guid.Empty;

            if (gCart != null)
            {
                cartGuid = gCart.CartGuid;
            }

            if (cartGuid == Guid.Empty)
            {
                return;
            }

            Cart cart = new Cart(cartGuid);

            if (cart.CartGuid != cartGuid)
            {
                return;
            }

            Store store = new Store(gCart.StoreGuid);

            if (store.Guid != cart.StoreGuid)
            {
                return;
            }

            gCart.DeSerializeCartOffers();

            gLog.SiteGuid  = store.SiteGuid;
            gLog.UserGuid  = gCart.UserGuid;
            gLog.CartGuid  = gCart.CartGuid;
            gLog.StoreGuid = gCart.StoreGuid;
            gLog.Save();

            gCart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address();


            gCart.OrderInfo.Completed = DateTime.UtcNow;
            if (newOrder.buyerbillingaddress.structuredname != null)
            {
                gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.structuredname.firstname;
                gCart.OrderInfo.CustomerLastName  = newOrder.buyerbillingaddress.structuredname.lastname;
            }
            else
            {
                gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.contactname;
                gCart.OrderInfo.CustomerLastName  = newOrder.buyerbillingaddress.contactname;
            }
            gCart.OrderInfo.CustomerEmail        = newOrder.buyerbillingaddress.email;
            gCart.OrderInfo.CustomerCompany      = newOrder.buyerbillingaddress.companyname;
            gCart.OrderInfo.CustomerAddressLine1 = newOrder.buyerbillingaddress.address1;
            gCart.OrderInfo.CustomerAddressLine2 = newOrder.buyerbillingaddress.address2;
            gCart.OrderInfo.CustomerCity         = newOrder.buyerbillingaddress.city;
            gCart.OrderInfo.CustomerState        = newOrder.buyerbillingaddress.region;
            gCart.OrderInfo.CustomerCountry      = newOrder.buyerbillingaddress.countrycode;
            gCart.OrderInfo.CustomerPostalCode   = newOrder.buyerbillingaddress.postalcode;
            gCart.OrderInfo.CustomerTelephoneDay = newOrder.buyerbillingaddress.phone;


            gCart.CopyCustomerToBilling();

            if (newOrder.buyershippingaddress.structuredname != null)
            {
                gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.structuredname.firstname;
                gCart.OrderInfo.DeliveryLastName  = newOrder.buyershippingaddress.structuredname.lastname;
            }
            else
            {
                gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.contactname;
                gCart.OrderInfo.DeliveryLastName  = newOrder.buyershippingaddress.contactname;
            }
            gCart.OrderInfo.DeliveryCompany    = newOrder.buyershippingaddress.companyname;
            gCart.OrderInfo.DeliveryAddress1   = newOrder.buyershippingaddress.address1;
            gCart.OrderInfo.DeliveryAddress2   = newOrder.buyershippingaddress.address2;
            gCart.OrderInfo.DeliveryCity       = newOrder.buyershippingaddress.city;
            gCart.OrderInfo.DeliveryState      = newOrder.buyershippingaddress.region;
            gCart.OrderInfo.DeliveryCountry    = newOrder.buyershippingaddress.countrycode;
            gCart.OrderInfo.DeliveryPostalCode = newOrder.buyershippingaddress.postalcode;

            gCart.TaxTotal = newOrder.orderadjustment.totaltax.Value;
            if (newOrder.ShippingCost > 0)
            {
                gCart.ShippingTotal = newOrder.ShippingCost;
            }
            gCart.OrderTotal = newOrder.ordertotal.Value;


            Guid orderStatusGuid = OrderStatus.OrderStatusReceivedGuid;


            if (
                (newOrder.financialorderstate == FinancialOrderState.CHARGEABLE) ||
                (newOrder.financialorderstate == FinancialOrderState.CHARGED) ||
                (newOrder.financialorderstate == FinancialOrderState.CHARGING)
                )
            {
                orderStatusGuid = OrderStatus.OrderStatusFulfillableGuid;
            }

            StoreHelper.EnsureUserForOrder(gCart);

            gCart.Save();

            //Currency currency = new Currency(store.DefaultCurrencyId);
            SiteSettings siteSettings = new SiteSettings(store.SiteGuid);

            Order order = Order.CreateOrder(
                store,
                gCart,
                gLog.RawResponse,
                gLog.OrderNumber,
                string.Empty,
                siteSettings.GetCurrency().Code,
                "GoogleCheckout",
                orderStatusGuid);

            //StoreHelper.ClearCartCookie(cart.StoreGuid);
            if (orderStatusGuid == OrderStatus.OrderStatusFulfillableGuid)
            {
                StoreHelper.ConfirmOrder(store, order);
                PayPalLog.DeleteByCart(order.OrderGuid);
            }

            if (orderStatusGuid == OrderStatus.OrderStatusReceivedGuid)
            {
                StoreHelper.ConfirmOrderReceived(store, order);
            }
        }