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);
            }
        }
コード例 #2
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)
 {
 }
コード例 #4
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();
        }