Esempio n. 1
0
        public static List <PendingOrder> GetOrdersInProcessing(string distributorId, string locale)
        {
            var request       = new GetPendingOrdersRequest_V01();
            var response      = new GetPendingOrdersResponse_V01();
            var pendingOrders = new List <PendingOrder>();

            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    using (var scope = new OperationContextScope(proxy.InnerChannel))
                    {
                        request.DistributorId = distributorId;
                        request.CountryCode   = locale;
                        response = proxy.GetOrders(new GetOrdersRequest1(request)).GetOrdersResult as GetPendingOrdersResponse_V01;
                        if (response != null && response.Status == ServiceResponseStatusType.Success)
                        {
                            pendingOrders = response.PendingOrders;
                        }
                        else
                        {
                            string debugLine = " DistributorId=" + distributorId +
                                               "; Errored while fetching pending payments orders";
                            throw new ApplicationException("OrdersProvider.GetOrders() Data: " + debugLine);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                }
            }

            return(pendingOrders);
        }
        // **********************************************************************************************
        private static List <CardInstallment> LoadInstallmentsConfigurationInfoFromService(string CountryCode,
                                                                                           DateTime applicationDate)
        {
            if (string.IsNullOrEmpty(CountryCode))
            {
                return(null);
            }

            var proxy    = ServiceClientProvider.GetOrderServiceProxy();
            var response =
                (RetrieveCardInstallmentsConfigurationResponse_V01)
                proxy.RetrieveCardInstallmentsConfiguration(new RetrieveCardInstallmentsConfigurationRequest1(new RetrieveCardInstallmentsConfigurationRequest_V01
            {
                CountryCode     = CountryCode,
                ApplicationDate = applicationDate
            })).RetrieveCardInstallmentsConfigurationResult;

            if (response != null && response.Status == ServiceResponseStatusType.Success &&
                response.Installments != null)
            {
                return(response.Installments);
            }

            return(null);
        }
Esempio n. 3
0
        protected override void GetOrderNumber()
        {
            // find a few items stuck in HPS MSMQ that NL DS 28Y0005736 has a space at the end "28Y0005736 " so HPS thrown exception and won't call RBS for IDEAL URL
            _distributorId = _distributorId.Trim();

            var proxy = ServiceClientProvider.GetOrderServiceProxy();
            GenerateOrderNumberRequest_V01 request = new GenerateOrderNumberRequest_V01();

            request.Amount        = _orderAmount;
            request.ClientName    = ClientName;
            request.Country       = _country;
            request.Currency      = _currency;
            request.DistributorID = _distributorId;
            request.GenerateHPSID = true;
            request.PayCode       = ("IDEAL-SSL.CreditCard".Contains(_paymentMethod)) ? "BW" : _paymentMethod;
            request.MerchantCode  = _config.MerchantAccountName;
            GenerateOrderNumberResponse_V01 response =
                OrderProvider.GenerateOrderNumber(request) as GenerateOrderNumberResponse_V01;

            if (null != response)
            {
                _orderNumber = response.OrderID;
                _url         = response.RedirectUrl;
                _orderNumber = response.OrderID;
                string orderData = _context.Session[PaymentGateWayOrder] as string;
                _context.Session.Remove(PaymentGateWayOrder);
                int recordId = OrderProvider.InsertPaymentGatewayRecord(_orderNumber, _distributorId, _gatewayName,
                                                                        orderData, _locale);
            }
        }
Esempio n. 4
0
        private static List <HPSCreditCardType> LoadFromService(string isoCountryCode)
        {
            using (var orderProxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var req = new GetCardTypesForCountryRequest_V01()
                    {
                        CountryCode = isoCountryCode,
                        OnlineOnly  = true,
                    };

                    var response = orderProxy.GetCardTypesForCountry(new GetCardTypesForCountryRequest1(req)).GetCardTypesForCountryResult as GetCardTypesForCountryResponse_V01;

                    if (response != null && response.HPSCreditCardTypes != null)
                    {
                        return(response.HPSCreditCardTypes);
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext <IOrderService>(ex, orderProxy);
                }
            }

            return(null);
        }
Esempio n. 5
0
        public string GetShipToTaxAreaId(MyHerbalife3.Ordering.ServiceProvider.OrderSvc.Address address)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var response = proxy.GetTaxAreaId(new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.GetTaxAreaIdRequest1(new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.GetTaxAreaIdRequest_V01 {
                    Address = address
                })).GetTaxAreaIdResult;
                if (null != response && response.Status == MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                {
                    var responseV01 = response as MyHerbalife3.Ordering.ServiceProvider.OrderSvc.GetTaxAreaIdResponse_V01;
                    if (null != responseV01)
                    {
                        return(responseV01.TaxAreaId);
                    }
                }
                LoggerHelper.Error("TaxAreaIdProvider: Error GetShipToTaxAreaId null");
                return(string.Empty);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("TaxAreaIdProvider: Error GetShipToTaxAreaId, error message:{0}",
                                                 ex.Message));
                return(string.Empty);
            }
            finally
            {
                proxy.Close();
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Gets the next valid invoice number for the given distributor
        /// </summary>
        /// <param name="distributorID">The ID of the distributor</param>
        /// <returns>The next valid invoice number</returns>
        public static Int64 GetNextDistributorInvoiceNumber(string distributorID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetNextDistributorInvoiceNumberRequest_V01
                {
                    DistributorID = distributorID
                };
                var response =
                    proxy.GetNextDistributorInvoiceNumber(new GetNextDistributorInvoiceNumberRequest1(request)).GetNextDistributorInvoiceNumberResult as GetNextDistributorInvoiceNumberResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success &&
                    response.InvoiceNumber > 0)
                {
                    return(response.InvoiceNumber);
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: GetNextDistributorInvoiceNumber\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(0);
        }
Esempio n. 7
0
        public static List <InvoiceSKU> GetInvoiceSKU(string distributorID, Int64 invoiceID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetInvoiceSkuRequest_V01
                {
                    DistributorID = distributorID,
                    InvoiceID     = invoiceID
                };
                var response = proxy.GetInvoiceSku(new GetInvoiceSkuRequest1(request)).GetInvoiceSkuResult as GetInvoiceSkuResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success &&
                    null != response.InvoiceSkus && response.InvoiceSkus.Count > 0)
                {
                    return(response.InvoiceSkus);
                }
                return(null);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: GetInvoiceSKU\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(null);
        }
Esempio n. 8
0
        public static Int64 SetInvoice(Invoice invoice)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new SetInvoiceRequest_V01
                {
                    Invoice = invoice
                };
                var response = proxy.SetInvoice(new SetInvoiceRequest1(request)).SetInvoiceResult as SetInvoiceResponse_V01;
                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    ExpireInvoicesCache(invoice.DistributorID);
                    return(response.InvoiceID);
                }
                return(0);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: SetInvoice\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(0);
        }
Esempio n. 9
0
        /// <summary>
        ///     method to get the check payment details response from service
        /// </summary>
        /// <param name="distributorID"></param>
        /// <returns></returns>
        private static GetInvoicesResponse_V01 getInvoicesResponse(string distributorID)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetInvoicesRequest_V01
                {
                    DistributorID = distributorID,
                };
                var response = proxy.GetInvoices(new GetInvoicesRequest1(request)).GetInvoicesResult as GetInvoicesResponse_V01;
                return(response);
            }
            catch (Exception ex)
            {
                WebUtilities.LogExceptionWithContext(ex);

                LoggerHelper.Exception("System.Exception", new Exception("OrderService: getInvoicesResponse\n", ex));
            }
            finally
            {
                if (proxy.State != CommunicationState.Closed)
                {
                    proxy.Close();
                }
                proxy = null;
            }
            return(null);
        }
Esempio n. 10
0
        public override void Submit()
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            var request = new GetVNPayPaymentServiceRequest_V01()
            {
                Amount       = _orderAmount.ToString(),
                CurrencyCode = _currency,
                OrderNumer   = _orderNumber,
            };

            var response = proxy.GetVNPayServiceBankUrl(new GetVNPayServiceBankUrlRequest(request)).GetVNPayServiceBankUrlResult as GetVNPayPaymentServiceResponse_V01;

            if (null != response)
            {
                LogMessage(PaymentGatewayLogEntryType.Request, this.OrderNumber, this._distributorId, this._gatewayName,
                           PaymentGatewayRecordStatusType.Unknown, response.VNResult);

                string[] strArr = response.VNResult.Split('|');
                if (strArr.Length > 2 && strArr[0] == "00")
                {
                    string redirectUrl = strArr[2];
                    HttpContext.Current.Response.Redirect(redirectUrl, true);
                }
            }
            else
            {
                LoggerHelper.Error("Unable to connect to VNPay");
            }
        }
        /// <summary>
        /// GetSKULimitationInfo
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, List <SKULimitationInfo> > GetSKULimitationInfo()
        {
            string cacheKey = "SKULIMITATION";
            var    limits   = HttpRuntime.Cache[cacheKey] as Dictionary <string, List <SKULimitationInfo> >;

            if (limits == null)
            {
                using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
                {
                    try
                    {
                        var rspSKU = proxy.GetSKULimitation(new GetSKULimitationRequest1(new GetSKULimitationRequest())).GetSKULimitationResult as GetSKULimitationResponse;
                        if (rspSKU != null && rspSKU.SKULimitationInfoDict != null)
                        {
                            limits = rspSKU.SKULimitationInfoDict;
                            HttpRuntime.Cache.Insert(cacheKey, rspSKU.SKULimitationInfoDict, null, DateTime.Now.AddMinutes(60 * 24), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        HL.Common.Utilities.WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                        LoggerHelper.Error(string.Format("GetSKULimitationInfo error, {0}", ex.ToString()));
                    }
                }
            }
            return(limits);
        }
        /// <summary>
        /// JP only : SKU limits
        /// </summary>
        /// <param name="distributorID"></param>
        /// <param name="orderMonth"></param>
        /// <returns></returns>
        public static List <PurchaseRestrictionInfo> SKUPurchaseRestrictionInfo(string distributorID, string orderMonth)
        {
            string cacheKey = string.Format("JPLIMITS_{0}_{1}", distributorID, orderMonth);
            var    limits   = HttpContext.Current.Session[cacheKey] as List <PurchaseRestrictionInfo>;

            if (limits != null)
            {
                return(limits);
            }
            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var rspSKU = proxy.SKUPurchaseRestriction(new SKUPurchaseRestrictionRequest1(new SKUPurchaseRestrictionRequest_V01 {
                        DistributorID = distributorID, OrderMonth = orderMonth
                    })).SKUPurchaseRestrictionResult as SKUPurchaseRestrictionResponse_V01;
                    if (rspSKU != null && rspSKU.PurchaseRestriction != null)
                    {
                        limits = rspSKU.PurchaseRestriction;
                        HttpContext.Current.Session[cacheKey] = limits;
                    }
                }
                catch (Exception ex)
                {
                    HL.Common.Utilities.WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                    LoggerHelper.Error(string.Format("SKUPurchaseRestrictionInfo error, {0}", ex.ToString()));
                }
            }
            return(limits);
        }
Esempio n. 13
0
        public static Order_V02 GetOrderDetail(string orderNumber)
        {
            Order_V02 order = null;
            var       proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                using (new OperationContextScope(proxy.InnerChannel))
                {
                    var req = new GetOrderDetailRequest_V01();
                    req.OrderNumber = orderNumber;
                    req.Locale      = Thread.CurrentThread.CurrentCulture.Name;
                    var response = proxy.GetOrderDetail(new GetOrderDetailRequest1(req)).GetOrderDetailResult as GetOrderDetailResponse_V01;
                    if (response != null)
                    {
                        return(response.Order);
                    }
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                ServiceClientFactory.Dispose(proxy);
            }

            return(order);
        }
 public static bool ImportPayments(string distributorID,
                                   string locale,
                                   PaymentInfoItemList paymentInfo,
                                   HttpSessionState session)
 {
     if (string.IsNullOrEmpty(distributorID))
     {
         return(false);
     }
     else
     {
         string country = (locale.Length > 2) ? locale.Substring(3) : locale;
         var    proxy   = ServiceClientProvider.GetOrderServiceProxy();
         var    request = new InsertPaymentInfoRequest_V01();
         foreach (PaymentInformation payment in paymentInfo)
         {
             request.PaymentInfo   = payment;
             request.DistributorID = distributorID;
             request.CountryCode   = country;
             var response =
                 proxy.InsertPaymentInfo(new InsertPaymentInfoRequest1(request)).InsertPaymentInfoResult as InsertPaymentInfoResponse_V01;
             if (response != null && response.Status != ServiceResponseStatusType.Success)
             {
                 ExceptionPolicy.HandleException(new Exception(response.Message),
                                                 ProviderPolicies.SYSTEM_EXCEPTION);
             }
         }
         //savePaymentInfoToCache(getCacheKey(distributorID, locale), ReloadPaymentInfo(distributorID, locale, session), session);
     }
     return(true);
 }
Esempio n. 15
0
        /// <summary>
        /// query fusion if there is outstanding orders
        /// </summary>
        /// <param name="country"></param>
        /// <param name="distributorId"></param>
        /// <returns></returns>
        private DistributorPurchasingLimitsSourceType GetDistributorPurchasingLimitsSource(string country, string distributorId)
        {
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                return(DistributorPurchasingLimitsSourceType.HMS);
            }

            if (PurchaseRestrictionProvider.IsBlackoutPeriod(country))
            {
                return(DistributorPurchasingLimitsSourceType.InternetOrdering);
            }

            var    source    = DistributorPurchasingLimitsSourceType.Unknown;
            string cacheKey  = string.Format("{0}_{1}_{2}", "FOP_PLSOURCE", country, distributorId);
            string useFusion = HttpRuntime.Cache[cacheKey] as string;

            if (useFusion == null)
            {
                if (!string.IsNullOrEmpty(distributorId) && !string.IsNullOrEmpty(country))
                {
                    try
                    {
                        var proxy   = ServiceClientProvider.GetOrderServiceProxy();
                        var request =
                            new GetDistributorPurchasingLimitsSourceRequest_V01();
                        request.DistributorID = distributorId;
                        request.CountryCode   = country;
                        // RS exception in country for request
                        if (country.Equals("RS"))
                        {
                            request.CountryCode = HL.Common.ValueObjects.CountryType.RS.HmsCountryCodes.FirstOrDefault();
                        }

                        var response = proxy.GetDistributorPurchasingLimitsSource(new GetDistributorPurchasingLimitsSourceRequest(request)).GetDistributorPurchasingLimitsSourceResult as GetDistributorPurchasingLimitsSourceResponse_V01;
                        if (response.Status != MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            LoggerHelper.Error(
                                string.Format("GetDistributorPurchasingLimitsSource failed for Distributor {0}, Country {1}, Status{2}",
                                              distributorId, country, response.Status));
                        }
                        if (null != response)
                        {
                            source    = response.Source;
                            useFusion = source == DistributorPurchasingLimitsSourceType.HMS ? Boolean.TrueString : Boolean.FalseString;
                            HttpRuntime.Cache.Insert(cacheKey, useFusion, null, DateTime.Now.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "Error retrieving OutstandingOrders Status from BPEL service for: DS:{0} - Country:{1}, {2}",
                                distributorId, country, ex));
                    }
                }
            }

            return(source = string.IsNullOrEmpty(useFusion) ? DistributorPurchasingLimitsSourceType.InternetOrdering : (useFusion.Equals(Boolean.TrueString) ? DistributorPurchasingLimitsSourceType.HMS : DistributorPurchasingLimitsSourceType.InternetOrdering));
        }
        private static PaymentInfoItemList loadPaymentInfoFromService(string distributorID, string locale)
        {
            if (string.IsNullOrEmpty(distributorID))
            {
                return(null);
            }

            string country = (locale.Length > 2) ? locale.Substring(3) : locale;
            var    proxy   = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    var response = proxy.GetPaymentInfo(new GetPaymentInfoRequest1(new GetPaymentInfoRequest_V02()
                    {
                        ID = 0, MaxCardsToGet = 0, DistributorID = distributorID, CountryCode = country
                    })).GetPaymentInfoResult as GetPaymentInfoResponse_V01;
                    if (response != null && response.Status == ServiceResponseStatusType.Success && response.PaymentInfoList != null)
                    {
                        var payInfoItems =
                            response.PaymentInfoList.GroupBy(p => string.Concat(p.CardNumber, "/", p.Alias)).Select(
                                g => g.First());
                        var distinctCards = new PaymentInfoItemList();
                        foreach (PaymentInformation pi in payInfoItems)
                        {
                            distinctCards.Add(pi);
                        }
                        return(distinctCards);
                    }
                }
                else
                {
                    var response = proxy.GetPaymentInfo(new GetPaymentInfoRequest1(new GetPaymentInfoRequest_V01()
                    {
                        ID = 0, MaxCardsToGet = 0, DistributorID = distributorID, CountryCode = country
                    })).GetPaymentInfoResult as GetPaymentInfoResponse_V01;
                    if (response != null && response.Status == ServiceResponseStatusType.Success && response.PaymentInfoList != null)
                    {
                        var payInfoItems =
                            response.PaymentInfoList.GroupBy(p => string.Concat(p.CardNumber, "/", p.Alias)).Select(
                                g => g.First());
                        var distinctCards = new PaymentInfoItemList();
                        foreach (PaymentInformation pi in payInfoItems)
                        {
                            distinctCards.Add(pi);
                        }
                        return(distinctCards);
                    }
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext <IOrderService>(ex, proxy);
            }

            return(null);
        }
Esempio n. 17
0
        public static List <Order_V02> GetOrders(string distributorId,
                                                 string distributorType,
                                                 DateTime?startDate,
                                                 DateTime?endDate,
                                                 bool isHapOrder,
                                                 string sortOrder)
        {
            GetOrdersResponse_V01 response;
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                //TODO: Remove scope? this is not being used... -Manuel Sauceda
                using (var scope = new OperationContextScope(proxy.InnerChannel))
                {
                    //var mhg = new MessageHeader<string>(authToken);
                    //var untyped = mhg.GetUntypedHeader("AuthToken", "ns");
                    //OperationContext.Current.OutgoingMessageHeaders.Add(untyped);

                    var sDate = (startDate == null) ? DateTime.Now.AddMonths(-3) : startDate.Value;
                    var eDate = (endDate == null) ? DateTime.Now : endDate.Value;

                    response = proxy.GetOrders(new GetOrdersRequest1(new GetOrdersRequest_V01
                    {
                        OrderFilter = new OrdersByDateRange
                        {
                            DistributorId   = distributorId,
                            DistributorType = distributorType,
                            StartDate       = sDate,
                            EndDate         = eDate,
                            IsHAPOrder      = isHapOrder
                        }
                    })).GetOrdersResult as GetOrdersResponse_V01;

                    if (response != null && response.Status == ServiceResponseStatusType.Success)
                    {
                        return(response.Orders);
                    }

                    string debugLine = " DistributorId=" + distributorId + "; DistributorType=" + distributorType +
                                       "; IsHAPOrder=" + isHapOrder;
                    throw new ApplicationException(
                              "OrderProvider.GetOrders() Error. Unsuccessful result from web service. Data: " + debugLine);
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                ServiceClientFactory.Dispose(proxy);
            }

            return(null);
        }
        public static OrderTotals GetQuote(Order order, OrderTotals total, bool calcFreight)
        {
            var order_V01 = order as Order_V01;
            var request   = new QuoteRequest_V02 {
                Order = order_V01, CalcFreight = calcFreight, Donation = (total as OrderTotals_V02) == null ? decimal.Zero : (total as OrderTotals_V02).Donation
            };
            var session = SessionInfo.GetSessionInfo(order.DistributorID, CultureInfo.CurrentCulture.Name);

            if (null != session)
            {
                SessionInfo.GetSessionInfo(order.DistributorID, CultureInfo.CurrentCulture.Name).HmsPricing = HLConfigManager.Configurations.CheckoutConfiguration.UseHMSCalc;
            }
            order.DistributorID = order.DistributorID.ToUpper();
            if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true")
            {
                LogRequest(OrderCreationHelper.Serialize(request));
            }
            QuoteResponse result = null;
            var           proxy  = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                result = proxy.Quote(new QuoteRequest1(request)).QuoteResult;
                if (result.Status == ServiceResponseStatusType.Success && result.Totals != null)
                {
                    if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true")
                    {
                        LogRequest(OrderCreationHelper.Serialize(result));
                    }
                    return(result.Totals);
                }
                else
                {
                    LoggerHelper.Error(
                        string.Format(
                            "Order Total error, distributor:{0} receive date:{1}, Calc Freight :{3},  error message:{2}",
                            order.DistributorID, order_V01.ReceivedDate.ToString(), order_V01.Messages, calcFreight));
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format(
                        "Order Total error, distributor:{0} receive date:{1}, Calc Freight:{3},  error message:{2}",
                        order.DistributorID, order_V01.ReceivedDate.ToString(), ex, calcFreight));
            }
            return(null);
        }
        private DistributorPurchasingLimitsCollection GetDistributorPurchasingLimitsCollection()
        {
            DistributorPurchasingLimitsCollection distributorPurchasingLimitsCollection = null;
            var mpeThresholdCountries =
                new List <string>(Settings.GetRequiredAppSetting("MPEThresholdCountries").Split(new[] { ',' }));

            if (mpeThresholdCountries.Contains(_processingCountry))
            {
                if (_distributorLevel == "DS")
                {
                    _currentLoggedInCountry = _processingCountry;
                }
            }
            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var request = new GetDistributorPurchasingLimitsRequest_V01
                    {
                        DistributorID = _distributorId,
                        CountryCode   = _currentLoggedInCountry
                    };

                    // RS exception in country for request
                    if (_currentLoggedInCountry.Equals("RS"))
                    {
                        request.CountryCode = CountryType.RS.HmsCountryCodes.FirstOrDefault();
                    }

                    var response =
                        proxy.GetDistributorPurchasingLimits(new GetDistributorPurchasingLimitsRequest(request)).GetDistributorPurchasingLimitsResult as GetDistributorPurchasingLimitsResponse_V01;
                    if (response != null && response.Status == ServiceResponseStatusType.Success)
                    {
                        distributorPurchasingLimitsCollection = response.PurchasingLimits;
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Exception("System.Exception", new Exception(
                                               string.Format(
                                                   "Error retrieving GetPurchasingLimits Status from Order service for: DS:{0} - Country:{1}, {2}",
                                                   _distributorId, _currentLoggedInCountry, ex)));
                    distributorPurchasingLimitsCollection = null;
                }
            }

            return(distributorPurchasingLimitsCollection);
        }
        private InvoiceModel GetInvoiceModel(int invoiceId, string locale, string memberId)
        {
            var proxy    = ServiceClientProvider.GetOrderServiceProxy();
            var response =
                proxy.GetMemberInvoice(new GetMemberInvoiceRequest1(new GetMemberInvoiceRequest_V01 {
                MemberInvoiceId = invoiceId
            })).GetMemberInvoiceResult;

            if (null == response || response.Status != ServiceResponseStatusType.Success)
            {
                return(null);
            }
            var responseV01 = response as GetMemberInvoiceResponse_V01;

            if (null != responseV01 && null != responseV01.MemberInvoice)
            {
                var invoiceModel = _invoiceConverter.ConvertToInvoiceModel(responseV01.MemberInvoice, locale);
                if (invoiceModel.MemberId.ToUpper() != memberId.ToUpper())
                {
                    LoggerHelper.Error(string.Format("InvoiceLoader: GetInvoiceModel error memberId mismatch: {0},{1}", memberId, invoiceModel.MemberId));
                    return(null);
                }
                if (invoiceModel.ReceiptChannel == "ClubSaleReceipt" || invoiceModel.ReceiptChannel == "Club Visit/Sale")
                {
                    invoiceModel.ClubInvoice  = _invoiceConverter.ConvertToClubInvoiceLines(responseV01.MemberInvoice.Items, invoiceModel);
                    invoiceModel.InvoiceLines = new List <InvoiceLineModel>();
                    invoiceModel.InvoicePrice = new InvoicePriceModel();
                    invoiceModel.InvoicePrice.DisplayCalculatedTax    = "0.00";
                    invoiceModel.InvoicePrice.DisplayDiscountedAmount = "0.00";
                    invoiceModel.InvoicePrice.DisplayMemberFreight    = "0.00";
                    invoiceModel.InvoicePrice.DisplayMemberTax        = "0.00";
                    invoiceModel.InvoicePrice.DisplayMemberTotal      = (Convert.ToDecimal(invoiceModel.ClubInvoice.ClubRecieptDisplayTotalDue).FormatPrice()).ToString();
                    invoiceModel.InvoicePrice.DisplayShipping         = "0.00";
                    invoiceModel.InvoicePrice.DisplaySubtotal         = (Convert.ToDecimal(invoiceModel.ClubInvoice.ClubRecieptDisplayTotalDue).FormatPrice()).ToString();
                    invoiceModel.InvoicePrice.DisplayTax            = "0.00";
                    invoiceModel.InvoicePrice.DisplayTotalDue       = (Convert.ToDecimal(invoiceModel.ClubInvoice.ClubRecieptDisplayTotalDue).FormatPrice()).ToString();
                    invoiceModel.InvoicePrice.DisplayTotalYourPrice = (Convert.ToDecimal(invoiceModel.ClubInvoice.ClubRecieptDisplayTotalDue).FormatPrice()).ToString();
                }
                else if (null != invoiceModel && null != responseV01.MemberInvoice.Items &&
                         responseV01.MemberInvoice.Items.Any())
                {
                    invoiceModel.InvoiceLines = _invoiceConverter.ConvertToInvoiceLines(
                        responseV01.MemberInvoice.Items, invoiceId);
                }
                return(invoiceModel);
            }
            return(null);
        }
        public static void SavePurchaseLimitsToStore(string country, string distributorId)
        {
            //2.CurrentOrderMonth
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                return;
            }
            var limits = getPurchasingLimitsFromCache(distributorId);

            if (null != limits && limits.Count > 0)
            {
                //var orderMonth = new OrderMonth(country);
                // orderMonth.ResolveOrderMonth();
                foreach (var limit in limits)
                {
                    var request = new SetPurchasingLimitsRequest_V01();
                    request.Country       = country;
                    request.DistributorId = distributorId;
                    request.OrderMonth    = limit.Key.ToString();

                    var purchasingLimit = limit.Value;
                    request.PurchasingLimits = purchasingLimit;

                    OrderServiceClient proxy = null;
                    try
                    {
                        proxy = ServiceClientProvider.GetOrderServiceProxy();
                        var response =
                            proxy.SetPurchasingLimits(new SetPurchasingLimitsRequest1(request)).SetPurchasingLimitsResult as SetPurchasingLimitsResponse_V01;
                        if (response.Status != ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            LoggerHelper.Error(
                                string.Format(
                                    "Save Purchasing Limits failed for Distributor {0}, Country {1}, Status{2}",
                                    distributorId, country, response.Status));
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format("Save PurchasingLimits failed for Distributor {0}, country Code: {1} {2}",
                                          distributorId, country, ex));
                    }
                }
            }
        }
        private static PaymentInfoItemList loadPaymentInfoFromService(string distributorID, string locale)
        {
            if (string.IsNullOrEmpty(distributorID))
            {
                return(null);
            }
            else
            {
                PaymentInfoItemList paymentInfo = null;
                try
                {
                    string country = (locale.Length > 2) ? locale.Substring(3) : locale;
                    var    proxy   = ServiceClientProvider.GetOrderServiceProxy();
                    var    request = new GetPaymentInfoRequest_V01()
                    {
                        ID = 0, MaxCardsToGet = 0, DistributorID = distributorID, CountryCode = country
                    };
                    request.GetFromHMSRegistry = true;
                    var response = proxy.GetPaymentInfo(new GetPaymentInfoRequest1(request)).GetPaymentInfoResult as GetPaymentInfoResponse_V01;
                    if (response != null &&
                        (response.Status == ServiceResponseStatusType.Success ||
                         response.Status == ServiceResponseStatusType.None)
                        // The None responce when the service retrieves an empty list
                        && response.PaymentInfoList != null)
                    {
                        paymentInfo = response.PaymentInfoList;
                        foreach (PaymentInformation pi in paymentInfo)
                        {
                            pi.BillingAddress = new Address_V01 {
                                Country = country
                            };
                        }
                        (new AsyncRegCreditCardProvider()).AsyncImportCardsToSQL(distributorID, locale,
                                                                                 response.PaymentInfoList,
                                                                                 paymentInfo.Count == 0);
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("Checkout - HMS reg card retrieve error: DS{0}: {1}", distributorID,
                                                     ex));
                }

                return(paymentInfo);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// WritePurchasingLimitsToDB
        /// </summary>
        /// <param name="limits"></param>
        private void WritePurchasingLimitsToDB(List <PurchasingLimits> limits)
        {
            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var currentLocalTime = HL.Common.Utilities.DateUtils.GetCurrentLocalTime(_currentLoggedInCountry);

                    foreach (PurchasingLimits l in limits)
                    {
                        PurchasingLimits_V01             lV01 = l as PurchasingLimits_V01;
                        PurchasingLimitRestrictionPeriod purchasingLimitRestrictionPeriod = HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionPeriod;
                        if (lV01.LimitsRestrictionType == LimitsRestrictionType.FOP || lV01.LimitsRestrictionType == LimitsRestrictionType.OrderThreshold)
                        {
                            purchasingLimitRestrictionPeriod = PurchasingLimitRestrictionPeriod.OneTime;
                        }
                        //else if (lV01.LimitsRestrictionType ==  HL.Order.ValueObjects.LimitsRestrictionType.OrderThreshold)
                        //    purchasingLimitRestrictionPeriod = PurchasingLimitRestrictionPeriod.Monthly;

                        var request = new SetPurchasingLimitsRequest_V02
                        {
                            DistributorId     = _distributorId,
                            Country           = _currentLoggedInCountry,
                            OrderMonth        = string.Format("{0}{1}", lV01.Year, lV01.Month),
                            PurchasingLimits  = lV01,
                            RestrictionPeriod = purchasingLimitRestrictionPeriod
                        };

                        var response =
                            proxy.SetPurchasingLimits(new SetPurchasingLimitsRequest1(request)).SetPurchasingLimitsResult as SetPurchasingLimitsResponse_V02;
                        if (response != null && response.Status == MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            HL.Common.Logging.LoggerHelper.Info("WritePurchasingLimitsToDB update successful");
                        }
                    }
                }
                catch (Exception ex)
                {
                    HL.Common.Logging.LoggerHelper.Exception("System.Exception", new Exception(
                                                                 string.Format(
                                                                     "Error WritePurchasingLimitsToDB for: DS:{0} - Country:{1}, {2}",
                                                                     _distributorId, _currentLoggedInCountry, ex)));
                }
            }
        }
Esempio n. 24
0
        public static BankSlipData GetBankSlipData(string orderNumber)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var request = new GetBankSlipReprintDataRequest_V01
                {
                    OrderNumber = orderNumber
                };

                var circuitBreaker =
                    CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBankSlipReprintDataResponse_V01>();

                var response =
                    circuitBreaker.Execute(() => proxy.GetBankSlipReprintData(new GetBankSlipReprintDataRequest1(request))).GetBankSlipReprintDataResult as
                    GetBankSlipReprintDataResponse_V01;

                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    return(response.BankSlipData);
                }
            }
            catch (Exception ex)
            {
                WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                if (null != proxy)
                {
                    if (proxy.State == CommunicationState.Faulted)
                    {
                        proxy.Abort();
                    }
                    else
                    {
                        proxy.Close();
                    }
                }
            }

            return(null);
        }
        private static ThreeDSecuredCreditCard Verify3DThroughSevice(ThreeDSecuredCreditCard threeDCard)
        {
            ThreeDSecuredCreditCard resultThreeDCard = threeDCard;

            var request = new Verify3DAuthenticationRequest_V01
            {
                ThreeDCard = threeDCard
            };

            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var response = proxy.Verify3DAuthentication(new Verify3DAuthenticationRequest1(request)).Verify3DAuthenticationResult as Verify3DAuthenticationResponse_V01;
                if (null != response && null != response.ThreeDCard && !string.IsNullOrEmpty(response.ThreeDCard.ProofXml))
                {
                    resultThreeDCard = response.ThreeDCard;
                    if (response.Status != ServiceResponseStatusType.Success)
                    {
                        resultThreeDCard.IsErrored = true;
                        resultThreeDCard.ProofXml  = string.Concat(resultThreeDCard.ProofXml, Environment.NewLine, string.Format("3D Verification Error: Order Service return error: {0}.", response.Message));
                    }
                }
                else
                {
                    resultThreeDCard.IsErrored = true;
                    resultThreeDCard.ProofXml  = string.Concat(resultThreeDCard.ProofXml, Environment.NewLine, string.Format("3D Verification Error: Order Service return empty ThreeDCard object; Order Service Error Message: {0}.", response.Message));
                }
            }
            catch (Exception ex)
            {
                resultThreeDCard.IsErrored = true;
                resultThreeDCard.ProofXml  = string.Concat(resultThreeDCard.ProofXml, Environment.NewLine, string.Format("3D Verification Error: Exception thrown while calling Order Service: {0}.", ex.ToString()));
                ex = new ApplicationException(string.Format("ThreeDPaymentProvider.Verify3DThroughSevice failed ", ex));
                HL.Common.Utilities.WebUtilities.LogServiceExceptionWithContext(ex, proxy);
            }
            finally
            {
                proxy.Close();
            }

            return(resultThreeDCard);
        }
Esempio n. 26
0
        public static bool InMaintenance()
        {
            bool isMaintenance = false;

            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    var response = proxy.InMaintenance(new InMaintenanceRequest());
                    if (response.InMaintenanceResult.Status == ServiceResponseStatusType.Success)
                    {
                        isMaintenance = response.InMaintenanceResult.InMaintenance;
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext(ex, proxy);
                }
            }
            return(isMaintenance);
        }
        public List <RecentOrderModel> GetRecentOrdersFromSource(string id, string countryCode)
        {
            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            try
            {
                var circuitBreaker =
                    CircuitBreakerFactory.GetFactory().GetCircuitBreaker <RecentOrderModel>();
                var response =
                    circuitBreaker.Execute(() => proxy.GetLatestOrder(new GetLatestOrderRequest1(new GetLatestOrderRequest_V01
                {
                    CountryCode   = countryCode,
                    DistributorId = id
                })).GetLatestOrderResult as GetLatestOrderResponse_V01);

                if (response != null && response.Status == ServiceResponseStatusType.Success)
                {
                    return(GetRecentOrdersModel(response.Orders.OfType <Order_V03>().ToList()));
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Exception("Error", ex,
                                       "Errored out in MyRecentOrdersSource" + countryCode);
                if (null != proxy)
                {
                    proxy.Close();
                }
                throw;
            }
            finally
            {
                if (null != proxy)
                {
                    proxy.Close();
                }
            }
            LoggerHelper.Error("Errored out in MyRecentOrdersSource Catalog service" + countryCode);
            return(null);
        }
Esempio n. 28
0
        public virtual CalculateTaxResponse CallModifiedPricing(ServiceProvider.OrderSvc.Order_V01 order)
        {
            var request = new ServiceProvider.OrderSvc.CalculateTaxRequest_V01()
            {
                Order = order
            };

            try
            {
                var proxy    = ServiceClientProvider.GetOrderServiceProxy();
                var response = proxy.CalculateTax(new CalculateTaxRequest1(request)).CalculateTaxResult;
                return(response);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format(
                        "OrderService - InvoiceProvider: An error occured while Calling CalculateTax service method {0}",
                        ex.Message));
            }
            return(null);
        }
 public static int DeletePaymentInfo(int id, string distributorID, string locale)
 {
     if (string.IsNullOrEmpty(distributorID))
     {
         return(0);
     }
     else
     {
         var proxy   = ServiceClientProvider.GetOrderServiceProxy();
         var request = new DeletePaymentInfoRequest_V01();
         request.DistributorID = distributorID;
         request.ID            = id;
         var response =
             proxy.DeletePaymentInfo(new DeletePaymentInfoRequest1(request)).DeletePaymentInfoResult as DeletePaymentInfoResponse_V01;
         if (response != null && response.Status == ServiceResponseStatusType.Success)
         {
             ReloadPaymentInfo(distributorID, locale);
             return(0);
         }
     }
     return(0);
 }
Esempio n. 30
0
        public virtual GetTaxDataForDwsFromVertexResponse CallDwsPricing(ServiceProvider.OrderSvc.CustomerOrder_V01 customerOrder)
        {
            var request = new GetTaxDataForDwsFromVertexRequest_V01()
            {
                Order = customerOrder
            };

            try
            {
                var proxy    = ServiceClientProvider.GetOrderServiceProxy();
                var response = proxy.GetTaxDataForDwsFromVertex(new GetTaxDataForDwsFromVertexRequest1(request)).GetTaxDataForDwsFromVertexResult;
                return(response);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format(
                        "OrderService - InvoiceProvider: An error occured while Calling GetTaxDataForDwsFromVertex service method {0}",
                        ex.Message));
            }
            return(null);
        }