Exemplo n.º 1
0
        // PUBLIC METHODS: ------------------------------------------------------------------------

        public int GetMerchantAmount(Merchant merchant, Item item)
        {
            string key = MerchantData.GetKey(merchant.uuid, item.uuid.ToString());

            if (!this.wares.ContainsKey(key))
            {
                int maxAmount = -1;
                for (int i = 0; maxAmount == -1 && i < merchant.warehouse.wares.Length; ++i)
                {
                    if (merchant.warehouse.wares[i].item.item != null &&
                        merchant.warehouse.wares[i].item.item.uuid == item.uuid)
                    {
                        if (merchant.warehouse.wares[i].limitAmount)
                        {
                            maxAmount = merchant.warehouse.wares[i].maxAmount;
                        }
                        else
                        {
                            maxAmount = int.MaxValue;
                        }
                    }
                }

                this.wares.Add(key, new MerchantData(merchant.uuid, item.uuid.ToString(), maxAmount));
            }

            return(this.wares[key].remainingAmount);
        }
    //private Dictionary<int, MerchantItemData> _mappedMerchantItemData = new Dictionary<int, MerchantItemData>();

    public MerchantData BuildMerchant(int id)
    {
        if (!_mappedMerchantData.ContainsKey(id))
        {
            DataService ds = new DataService("merchants.bytes");

            MerchantData loaded = ds.GetItemMatching <MerchantData>(x => x.id == id);

            if (loaded != null)
            {
                _mappedMerchantData.Add(loaded.id, loaded);
                IEnumerable <MerchantItemData> items = ds.GetItemsMatching <MerchantItemData>(x => x.merchantId == id);

                foreach (MerchantItemData item in items)
                {
                    loaded.AddItem(item);
                }

                return(loaded);
            }
        }
        else
        {
            return(_mappedMerchantData[id]);
        }

        return(null);
    }
Exemplo n.º 3
0
        public bool BuyFromMerchant(Merchant merchant, Item item, int buyAmount)
        {
            int curAmount = this.GetMerchantAmount(merchant, item);

            int remainingAmount = curAmount - buyAmount;

            if (remainingAmount < 0)
            {
                return(false);
            }

            if (InventoryManager.Instance.BuyItem(item.uuid, buyAmount, merchant))
            {
                string key = MerchantData.GetKey(merchant.uuid, item.uuid.ToString());
                if (!this.wares.ContainsKey(key))
                {
                    this.wares.Add(
                        key,
                        new MerchantData(merchant.uuid, item.uuid.ToString(), remainingAmount)
                        );
                }
                else
                {
                    this.wares[key].remainingAmount = remainingAmount;
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
    public void SaveAmmoAmont()
    {
        MerchantData m = gameControl.control.merchs.FirstOrDefault(i => i.merchantName == gameObject.name);

        m.basicAmmo   = basicAmmo;
        m.rapidAmmo   = rapidAmmo;
        m.shotgunAmmo = shotgunAmmo;
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        MerchantData m = gameControl.control.merchs.FirstOrDefault(i => i.merchantName == gameObject.name);

        //load merchant's items
        if (m != null)
        {
            mitems      = new List <Item>();
            mitems      = m.merchantItems;
            basicAmmo   = m.basicAmmo;
            rapidAmmo   = m.rapidAmmo;
            shotgunAmmo = m.shotgunAmmo;
        }
        else if (m == null)
        {
            if (swords != null)
            {
                foreach (Weapon w in swords)
                {
                    mitems.Add(w);
                }
            }

            if (guns != null)
            {
                foreach (Gun g in guns)
                {
                    mitems.Add(g);
                }
            }

            if (books != null)
            {
                foreach (Book b in books)
                {
                    mitems.Add(b);
                }
            }

            if (items.ownedItems != null)
            {
                foreach (Item i in items.ownedItems)
                {
                    CheckItemDuplicates(i.name);
                }
            }

            gameControl.control.merchs.Add(new MerchantData()
            {
                merchantName  = gameObject.name,
                basicAmmo     = basicAmmo,
                rapidAmmo     = rapidAmmo,
                shotgunAmmo   = shotgunAmmo,
                merchantItems = mitems
            });
        }
    }
Exemplo n.º 6
0
        public virtual TaskStatus OnUpdate()
        {
            if (!Object.op_Inequality((Object)this.MainTargetInSightMerchantPoint, (Object)null))
            {
                return((TaskStatus)1);
            }
            this.TargetInSightMerchantPoint     = this.MainTargetInSightMerchantPoint;
            this.MainTargetInSightMerchantPoint = (MerchantPoint)null;
            MerchantData merchantData = this.Merchant.MerchantData;

            merchantData.PointPosition     = ((Component)this.TargetInSightMerchantPoint).get_transform().get_position();
            merchantData.MainPointPosition = new Vector3(-999f, -999f, -999f);
            return((TaskStatus)2);
        }
        public virtual TaskStatus OnUpdate()
        {
            if (!this.Success && !this.EndFlag.get_Value() && this.nextPointSettingDisposable != null)
            {
                return((TaskStatus)3);
            }
            if (!this.Success)
            {
                return((TaskStatus)1);
            }
            MerchantData merchantData = this.Merchant.MerchantData;

            merchantData.PointPosition     = !Object.op_Inequality((Object)this.TargetInSightMerchantPoint, (Object)null) ? new Vector3(-999f, -999f, -999f) : ((Component)this.TargetInSightMerchantPoint).get_transform().get_position();
            merchantData.MainPointPosition = !Object.op_Inequality((Object)this.MainTargetInSightMerchantPoint, (Object)null) ? new Vector3(-999f, -999f, -999f) : ((Component)this.MainTargetInSightMerchantPoint).get_transform().get_position();
            return((TaskStatus)2);
        }
Exemplo n.º 8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MerchantData.Length != 0)
            {
                hash ^= MerchantData.GetHashCode();
            }
            hash ^= transactions_.GetHashCode();
            hash ^= refundTo_.GetHashCode();
            if (Memo.Length != 0)
            {
                hash ^= Memo.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 9
0
    private MerchantData[] GetMerchants()
    {
        MerchantData[] merchantsData = new MerchantData[merchants.Count];

        for (int index = 0; index < merchants.Count; index++)
        {
            if (merchants[index] != null)
            {
                Vector3 position  = merchants[index].transform.position;
                float[] transform = new float[3] {
                    position.x, position.y, position.z
                };
                merchantsData[index] = new MerchantData(merchants[index].GetName(), merchants[index].GetItemsData(), transform);
            }
        }

        return(merchantsData);
    }
Exemplo n.º 10
0
        public void OnLoad(object generic)
        {
            MerchantSaveData saveData = (MerchantSaveData)generic;

            this.wares = new Dictionary <string, MerchantData>();

            for (int i = 0; i < saveData.warehouses.Count; ++i)
            {
                MerchantData saveDataItem = saveData.warehouses[i];
                string       key          = MerchantData.GetKey(saveDataItem.merchantID, saveDataItem.itemID);

                if (this.wares.ContainsKey(key))
                {
                    continue;
                }
                this.wares.Add(key, saveDataItem);
            }
        }
    public void Begin(MerchantData merchant)
    {
        merchantData = merchant;

        _currState      = State.Buy;
        numPlayerSets   = PlayerData.Instance.characterList.GetNumSets(3);
        numMerchantSets = Mathf.CeilToInt(merchantData.numItems / 3f);

        currPlayerSetIndex   = 0;
        currMerchantSetIndex = 0;

        merchantCard.UpdateHeader(merchantData.name);
        merchantCard.UpdateMerchantItemCards(merchantData.TakeSet(currMerchantSetIndex, 3));
        merchantCard.UpdatePlayerItemCards(PlayerData.Instance.characterList.TakeSet(currPlayerSetIndex, 3));

        merchantCard.Show(true);
        characterCard.Show(true);
    }
Exemplo n.º 12
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();
        }
        private Cart DeserializeCart(MerchantData merchantData)
        {
            if (merchantData == null)
            {
                return(null);
            }
            if (merchantData.SerializedObject.Length == 0)
            {
                return(null);
            }


            object objCart = SerializationHelper.DeserializeFromString(typeof(Cart), SerializationHelper.RestoreXmlDeclaration(merchantData.SerializedObject));

            if (objCart != null)
            {
                return(objCart as Cart);
            }


            return(null);
        }
Exemplo n.º 14
0
        private bool IsMatchPoint(MerchantPoint _point, bool _isMiddlePoint)
        {
            if (Object.op_Equality((Object)_point, (Object)null))
            {
                return(false);
            }
            Merchant.EventType eventType    = !_isMiddlePoint ? Merchant.EventType.Search : Merchant.EventType.Wait;
            MerchantActor      merchant     = this.Merchant;
            MerchantData       merchantData = merchant.MerchantData;
            int           openAreaId        = merchant.OpenAreaID;
            int           pointAreaId       = merchantData.PointAreaID;
            int           pointGroupId      = merchantData.PointGroupID;
            MerchantPoint prevMerchantPoint = this.PrevMerchantPoint;

            if (openAreaId < _point.AreaID || (_point.EventType & eventType) != eventType || _point.AreaID != pointAreaId)
            {
                return(false);
            }
            if (_isMiddlePoint)
            {
                return(_point.GroupID == 0);
            }
            return(_point.GroupID != pointGroupId || Object.op_Inequality((Object)_point, (Object)prevMerchantPoint));
        }
Exemplo n.º 15
0
        void btnGoogleCheckout_Click(object sender, ImageClickEventArgs e)
        {
            if (
                (store != null) &&
                (cart != null)
                )
            { //&& (IsValidForCheckout()) ?
                int cartTimeoutInMinutes = 30;

                CheckoutShoppingCartRequest Req = new CheckoutShoppingCartRequest(
                    commerceConfig.GoogleMerchantID,
                    commerceConfig.GoogleMerchantKey,
                    commerceConfig.GoogleEnvironment,
                    siteSettings.GetCurrency().Code,
                    cartTimeoutInMinutes);


                foreach (CartOffer cartOffer in cart.CartOffers)
                {
                    Req.AddItem(
                        cartOffer.Name,
                        string.Empty,
                        cartOffer.OfferPrice,
                        cartOffer.Quantity);
                }

                //Req.AddMerchantCalculatedShippingMethod
                //Req.AnalyticsData
                //Req.ContinueShoppingUrl
                //Req.EditCartUrl

                //Req.RequestInitialAuthDetails
                //Req.AddParameterizedUrl

                // we need to serialize the cart and it items to xml here
                // so when we get it back from google
                // we can validate against the existing cart
                // as its possible items were added to the cart
                // after we passed the user to google

                //Req.MerchantPrivateData = cart.CartGuid.ToString();
                //cart.SerializeCartOffers();
                //Req.MerchantPrivateData = SerializationHelper.SerializeToSoap(cart);

                cart.SerializeCartOffers();
                MerchantData merchantData = new MerchantData();
                merchantData.ProviderName     = "WebStoreGCheckoutNotificationHandlerProvider";
                merchantData.SerializedObject = SerializationHelper.RemoveXmlDeclaration(SerializationHelper.SerializeToString(cart));
                Req.MerchantPrivateData       = SerializationHelper.RemoveXmlDeclaration(SerializationHelper.SerializeToString(merchantData));
                Req.RequestBuyerPhoneNumber   = true;

                // flat rate shipping example
                //Req.AddFlatRateShippingMethod("UPS Ground", 5);

                //Add a rule to tax all items at 7.5% for Ohio
                //Req.AddStateTaxRule("NC", .15, true);
                //TODO: lookup tax

                GCheckoutResponse Resp = Req.Send();

                if (Resp.IsGood)
                {
                    Response.Redirect(Resp.RedirectUrl, true);
                }
                else
                {
                    lblMessage.Text = Resp.ErrorMessage;
                }
            }
        }
Exemplo n.º 16
0
        private void EndMerchantStory0()
        {
            this._eventPoint.SetDedicatedNumber(1);
            MapUIContainer.SetVisibleHUD(true);
            if (!Singleton <Manager.Map> .IsInstance())
            {
                return;
            }
            Manager.Map instance = Singleton <Manager.Map> .Instance;
            instance.SetActiveMapEffect(true);
            MerchantActor merchant     = instance.Merchant;
            MerchantData  merchantData = merchant.MerchantData;

            if (Object.op_Inequality((Object)merchant, (Object)null))
            {
                if (merchantData != null)
                {
                    merchantData.Unlock = true;
                }
                merchant.SetLookPtn(0, 3);
                merchant.SetLookTarget(0, 0, (Transform)null);
                merchant.ChangeBehavior(merchant.LastNormalMode);
            }
            AgentActor tutorialAgent = instance.TutorialAgent;

            if (Object.op_Inequality((Object)tutorialAgent, (Object)null))
            {
                tutorialAgent.ChangeFirstNormalBehavior();
                instance.TutorialAgent = (AgentActor)null;
                Manager.Map.SetTutorialProgressAndUIUpdate(16);
            }
            PlayerActor player = instance.Player;

            if (Object.op_Inequality((Object)player, (Object)null))
            {
                if (Manager.Config.GraphicData.CharasEntry[0])
                {
                    player.CameraControl.Mode = CameraMode.Normal;
                    player.PlayerController.ChangeState("Idle");
                    ObservableExtensions.Subscribe <long>(Observable.Take <long>(Observable.SkipWhile <long>((IObservable <M0>)Observable.EveryUpdate(), (Func <M0, bool>)(_ => player.CameraControl.CinemachineBrain.get_IsBlending())), 1), (System.Action <M0>)(_ =>
                    {
                        player.AddTutorialUI(Popup.Tutorial.Type.Girl, false);
                        player.PlayerController.ChangeState("Normal");
                    }));
                }
                else
                {
                    player.PlayerController.ChangeState("Idle");
                    Singleton <Manager.Map> .Instance.ApplyConfig((System.Action)(() =>
                    {
                        // ISSUE: cast to a reference type
                        // ISSUE: explicit reference operation
                        CinemachineBlendDefinition.Style prevStyle = (CinemachineBlendDefinition.Style)(^ (CinemachineBlendDefinition&)ref player.CameraControl.CinemachineBrain.m_DefaultBlend).m_Style;
                        // ISSUE: cast to a reference type
                        // ISSUE: explicit reference operation
                        (^ (CinemachineBlendDefinition&)ref player.CameraControl.CinemachineBrain.m_DefaultBlend).m_Style = (__Null)0;
                        player.CameraControl.Mode = CameraMode.Normal;
                        // ISSUE: cast to a reference type
                        // ISSUE: explicit reference operation
                        ObservableExtensions.Subscribe <long>(Observable.Take <long>(Observable.Skip <long>((IObservable <M0>)Observable.EveryLateUpdate(), 1), 1), (System.Action <M0>)(_ => (^ (CinemachineBlendDefinition&)ref player.CameraControl.CinemachineBrain.m_DefaultBlend).m_Style = (__Null)prevStyle));
                    }), (System.Action)(() =>
                    {
                        player.AddTutorialUI(Popup.Tutorial.Type.Girl, false);
                        player.PlayerController.ChangeState("Normal");
                    }));
                }
            }
            Singleton <Manager.Map> .Instance.SetBaseOpenState(-1, true);

            instance.Simulator.EnabledTimeProgression = true;
        }
Exemplo n.º 17
0
 public override void HandleNewOrderNotificationExtended(
     string requestXml,
     NewOrderNotificationExtended newOrder,
     MerchantData merchantData)
 {
 }
Exemplo n.º 18
0
        //public abstract void RebuildIndex(
        //    PageSettings pageSettings,
        //    string indexPath);

        public abstract void HandleNewOrderNotificationExtended(
            string requestXml,
            NewOrderNotificationExtended newOrder,
            MerchantData merchantData);
Exemplo n.º 19
0
        public async Task <IActionResult> Index()
        {
            try {
                #region Qurey Booking Data from MySql then add to object
                TimeSpan fromTime = new TimeSpan(7, 0, 0);
                TimeSpan toTime   = new TimeSpan(20, 0, 0);
                var      from     = (DateTime.Now.Date).Add(fromTime);
                var      to       = DateTime.Now.Date.Add(toTime);
                var      strSql   = $"select '' as No,'' as QRCode,substring(item.barcode, 2, 12) as Reference1,'' as Reference2,'' as Reference3,'' as Reference4,if (parcels.cod_amount > 0 ,'True','False')as IsPOSTPAY,if (parcels.cod_amount > 0 ,parcels.cod_amount,0)as POSTPAYAmount,parcels.recipient_name as ReceiveName,parcels.recipient_tel as Mobile,'' as Mobile2,parcels.recipient_address as Address,'' as Subdistrict,if (parcels.recipient_district <> '',parcels.recipient_district,postalCode.district)as District,postalCode.province as Province,parcels.recipient_zipcode as PostalCode,parcels.user_note as Remark,'' as ExchangeType,'' as ExchangeRemark,'' as Email,'' as Email2,1 as ItemNo,'' as SupplierSKU,'' as VendorSKU,'' as MerchantSKU,'' as ProductEANUPC,'Products 1' as ProductName,'' as ProductSize,'' as ProductColor,1 as ProductQuantity,'' as FulfillmentRemark,org.name as MerchantName,postalCode.province as MerchantAddress,org.name as MerchantContactPerson,org.phone as MerchantMobile ,orgGeo.json_info as GeographicLocation from tbl_manifest_items item left join tbl_manifest_sheets sheet on sheet.id = item.sheet_id left join tbl_scg_parcels parcels on parcels.tracking_number = item.barcode left join tbl_scg_postalCode postalCode on postalCode.postal_code = parcels.recipient_zipcode left join tbl_organization org on org.customer_code = parcels.sender_code left join tbl_auth_users user on user.id = item.user_created left join tbl_organization orgGeo on orgGeo.organization_id = user.organization_id where sheet.branch_destination = 'Alpha Fast' and item.status_deleted = 'N' and item.date_created between '2020-03-31' and '2020-03-31 20:00:00' and org.name is not null group by item.barcode";

                var data = await appQuery.AlphaBookingViewModelsAsync <AlphaBookingViewModel>(strSql);

                var merchantName = from x in data.ToList() group x by x.MerchantName into g orderby g.Key
                                   select new {
                    MerchantName          = g.FirstOrDefault().MerchantName,
                    MerchantAddress       = g.FirstOrDefault().MerchantAddress,
                    MerchantContactPerson = g.FirstOrDefault().MerchantContactPerson,
                    IsNewReturn           = false,
                    Province    = g.FirstOrDefault().Province,
                    District    = g.FirstOrDefault().District,
                    Subdistrict = g.FirstOrDefault().Subdistrict,
                    Latitude    = g.FirstOrDefault().GeographicLocation.Split('"').ToArray(),
                    Longitude   = g.FirstOrDefault().GeographicLocation.Split('"').ToArray(),
                };
                List <MerchantData> merchantDatas = new List <MerchantData>();
                var    i      = 0;
                Random random = new Random();

                foreach (var m in merchantName)
                {
                    List <BookingData> bookingDatas = new List <BookingData>();
                    var bookings = data.Where(x => x.MerchantName == m.MerchantName);
                    foreach (var b in bookings)
                    {
                        var         ran         = random.Next(111111111, 999999999);
                        var         mobile      = CorrectMobile(b.Mobile);
                        BookingData bookingData = new BookingData()
                        {
                            QRCode         = $"SCG{ran}",
                            Reference1     = b.Reference1,
                            CustomerRemark = null,
                            IsPOSTPAY      = b.IsPOSTPAY == "True" ? true : false,
                            Amount         = b.POSTPAYAmount,
                            Firstname      = b.ReceiveName.Length <= 50 ? b.ReceiveName : b.ReceiveName.Substring(0, 50),
                            Lastname       = b.ReceiveName.Length <= 50 ? b.ReceiveName : b.ReceiveName.Substring(0, 50),
                            Mobile         = util.CorrectMobileFormat(b.Mobile),
                            Address        = b.Address,
                            Province       = b.Province,
                            district       = b.District,
                            Subdistrict    = b.Subdistrict,
                            PostalCode     = b.PostalCode,
                            IsExchange     = false,
                            IsIVR          = false,
                            IsInsurance    = false,
                            IsSameDay      = false
                        };
                        bookingDatas.Add(bookingData);
                    }

                    MerchantData merchantData = new MerchantData()
                    {
                        MerchantName          = m.MerchantName,
                        MerchantAddress       = m.MerchantAddress,
                        MerchantContactPerson = m.MerchantContactPerson,
                        IsNewReturn           = false,
                        Province    = m.Province,
                        District    = m.District,
                        Subdistrict = m.Subdistrict,
                        Latitude    = 13.736831,  //Convert.ToDouble(m.Latitude[3]),
                        Longitude   = 100.606181, //Convert.ToDouble(m.Longitude[7]),
                        BookingData = bookingDatas
                    };
                    merchantDatas.Add(merchantData);

                    DeliveryOrderRequest deliveryOrder = new DeliveryOrderRequest()
                    {
                        MerchantData      = merchantDatas,
                        AppointmentDateId = 2,
                        AppointmentTimeId = 18
                    };

                    i++;
                    //if (i >= 1) {
                    //    break;
                    //}
                }
                DeliveryOrderRequest orderRequests = new DeliveryOrderRequest()
                {
                    MerchantData      = merchantDatas,
                    AppointmentDateId = 0,
                    AppointmentTimeId = 0
                };
                #endregion
                #region Call Alpha api usign Restsharp
                var c = new RestClient("https://apialpha.alphauat.com");
                var r = new RestRequest("api/DeliveryOrder/MarketPlaceDeliveryOrderEntry", Method.POST);
                r.AddHeader("Authorization", "Alpha vxkx619iHkU5JXLWdXVE5WQX731C18D45crxFoe9N4NI1ltTl98QpztHGB/Q8l9JLFB+vdH/zFbA3T+9LNVWZMx94swrLieqn0tLjVq6lpYn6IOT3jgNmaGfWx5sbU12Qlx+LxSrK11TUcjhDYRN2KAxjGlrhMFIk73rp3cOBv74acFjFvZQnYWZ/QUxFkThZY2UfQettfR9zbaVF4MkBH0rG+WyOFhz10a42peh65G3z0ShrKJ+MvvBMcZLf+t8jYJ/neNIC0YCQevkfaDJY5IofeIfpsLzgMrYzD2NObCcMpK1ZfUZE/Qrp/NNTPCm4hFFQfMkg/DPEO2qp52HVhBCOVvC3pxs");

                var serealize = JsonSerializer.Serialize <DeliveryOrderRequest>(orderRequests);
                r.AddJsonBody(orderRequests);
                var res   = c.Execute(r);
                var model = JsonSerializer.Deserialize <CreateBookingModel>(res.Content);

                #endregion

                return(View());
            } catch (Exception ex) {
                string messages = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                throw;
            }
        }
        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);
            }
        }