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); }
private bool DoImportPaymentAsync(string distributorID, string locale, PaymentInfoItemList payments, HttpSessionState session) { return(PaymentInfoProvider.ImportPayments(distributorID, locale, payments, session)); }
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); }
private static void savePaymentInfoToCache(string cacheKey, PaymentInfoItemList payments, HttpSessionState session) { if (payments != null) { if (null != HttpContext.Current) { var thisSession = (((null != session) ? session : HttpContext.Current.Session)); thisSession[cacheKey] = payments; } } }
private static PaymentInfoItemList getPaymentInfo(string distributorID, string locale) { PaymentInfoItemList result = null; try { result = loadPaymentInfoFromService(distributorID, locale); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } return(result); }
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); } }
public IAsyncResult AsyncImportCardsToSQL(string distributorID, string locale, PaymentInfoItemList payments, bool remove) { IAsyncResult ar; if (remove == false) { DoImportPaymentDelegate doDelegate = DoImportPaymentAsync; ar = doDelegate.BeginInvoke(distributorID, locale, payments, HttpContext.Current.Session, ImportCardsCallback, null); } else { DoDeletePaymentDelegate doDelegate = DoRemovePaymentAsync; ar = doDelegate.BeginInvoke(distributorID, locale, HttpContext.Current.Session, DeleteCardsCallback, null); } return(ar); }
private static PaymentInfoItemList getGetPaymentInfoFromCache(string distributorID, string locale) { PaymentInfoItemList result = null; if (string.IsNullOrEmpty(distributorID) || string.IsNullOrEmpty(locale)) { return(result); } // cache is getting messed up on adding new // gets cache key string cacheKey = getCacheKey(distributorID, locale); // tries to get object from cache try { if (HttpContext.Current != null) { var session = HttpContext.Current.Session; if (session != null) { //ExceptionFix: Validating if object exist in cache before cast if (session[cacheKey] != null) { result = session[cacheKey] as PaymentInfoItemList; } } } } catch (Exception ex) { Trace.TraceError(ex.InnerException.ToString()); Trace.TraceError(ex.StackTrace); ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } return(result); }
public bool ImportPayments(string distributorID, string locale, PaymentInfoItemList paymentInfo, HttpSessionState session) { return(PaymentInfoProvider.ImportPayments(distributorID, locale, paymentInfo, session)); }
private static void savePaymentInfoToCache(string cacheKey, PaymentInfoItemList payments) { savePaymentInfoToCache(cacheKey, payments, null); }
public static int SavePaymentInfo(string distributorID, string locale, PaymentInformation paymentInfo) { if (string.IsNullOrEmpty(distributorID)) { return(0); } if (paymentInfo.IsTemporary) { Trace.TraceWarning("Method: SavePaymentInfo Distributor:'{0}' Locate: '{1}'", distributorID, locale); var payments = getGetPaymentInfoFromCache(distributorID, locale); if (null == payments) { payments = new PaymentInfoItemList(); savePaymentInfoToCache(getCacheKey(distributorID, locale), payments); } PaymentInformation existing = null; try { existing = payments.Find(p => p.ID == paymentInfo.ID); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } if (null != existing) { payments.Remove(existing); } payments.Add(paymentInfo); return(0); } else { var proxy = ServiceClientProvider.GetOrderServiceProxy(); try { string country = (locale.Length > 2) ? locale.Substring(3) : locale; if (HLConfigManager.Configurations.DOConfiguration.IsChina) { var request = new InsertPaymentInfoRequest_V02(); request.PaymentInfo = paymentInfo; request.DistributorID = distributorID; request.CountryCode = country; var response = proxy.InsertPaymentInfo(new InsertPaymentInfoRequest1(request)).InsertPaymentInfoResult as InsertPaymentInfoResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { ReloadPaymentInfo(distributorID, locale); return(response.ID); } } else { var request = new InsertPaymentInfoRequest_V01(); request.PaymentInfo = paymentInfo; request.DistributorID = distributorID; request.CountryCode = country; var response = proxy.InsertPaymentInfo(new InsertPaymentInfoRequest1(request)).InsertPaymentInfoResult as InsertPaymentInfoResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { ReloadPaymentInfo(distributorID, locale); return(response.ID); } } } catch (Exception ex) { WebUtilities.LogServiceExceptionWithContext <ServiceProvider.OrderSvc.IOrderService>(ex, proxy); } } return(0); }
public static PaymentInfoItemList ReloadPaymentInfo(string distributorID, string locale, HttpSessionState aSession) { var payments = new PaymentInfoItemList(); try { string cacheKey = getCacheKey(distributorID, locale); var session = ((null != aSession) ? aSession : HttpContext.Current.Session); if (session == null) { return(payments); } var current = (session)[cacheKey] as PaymentInfoItemList; List <PaymentInformation> tempPayments = null; if (null != current && current.Count > 0) { tempPayments = (from t in current where t.IsTemporary select t).ToList(); } payments = loadPaymentInfoFromService(distributorID, locale); if (null != current && null != payments) { foreach (PaymentInformation pi in current) { var c = payments.Find(p => p.ID == pi.ID); // (from p in payments where p.ID == pi.ID select p); if (c != null) { c.AuthorizationFailures = pi.AuthorizationFailures; } } } if (null != tempPayments && tempPayments.Count > 0) { payments.AddRange(tempPayments); } if (payments != null) { try { savePaymentInfoToCache(cacheKey, payments); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } } else { session.Remove(cacheKey); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION); } return(payments); }