public JsonNetResult RefundPayment(string accountId, string chargeId, decimal refundAmount) { DataAccessResponseType response = null; if (string.IsNullOrEmpty(accountId)) { response = new DataAccessResponseType { isSuccess = false, ErrorMessage = "Cannot apply refunds on closed/null accounts." }; } else { var user = AuthenticationCookieManager.GetAuthenticationCookie(); if (response == null) { var accountBillingServiceClient = new AccountBillingService.AccountBillingServiceClient(); try { accountBillingServiceClient.Open(); response = accountBillingServiceClient.RefundPayment( accountId, chargeId, refundAmount, AuthenticationCookieManager.GetAuthenticationCookie().Id, PlatformAdminSite.AccountBillingService.RequesterType.PlatformUser, Common.SharedClientKey );//, //user.Id, //PlatformAdminSite.AccountManagementService.RequesterType.PlatformUser).ToList(); //Close the connection WCFManager.CloseConnection(accountBillingServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountBillingServiceClient, exceptionMessage, currentMethodString); #endregion } } } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public JsonNetResult GetNextInvoice(string accountId) { var user = AuthenticationCookieManager.GetAuthenticationCookie(); Invoice invoice = null; #region (Plan A) Get data from Redis Cache /* * try * { * IDatabase cache = CoreServiceSettings.RedisConnectionMultiplexers.AccountManager_Multiplexer.GetDatabase(); * * string hashKey = "accountbyid:" + accountId.ToString().Replace("-", ""); * string hashField = "creditcard"; * * var redisValue = cache.HashGet(hashKey, hashField); * * if (redisValue.HasValue) * { * accountCreditCardInfo = JsonConvert.DeserializeObject<AccountCreditCardInfo>(redisValue); * } * } * catch (Exception e) * { * var error = e.Message; * //TODO: Log: error message for Redis call * }*/ #endregion if (invoice == null) { #region (Plan B) Get data from WCF var accountBillingServiceClient = new AccountBillingService.AccountBillingServiceClient(); try { accountBillingServiceClient.Open(); invoice = accountBillingServiceClient.GetUpcomingInvoice( accountId, Common.SharedClientKey);//, //user.Id, //PlatformAdminSite.AccountManagementService.RequesterType.PlatformUser); //Close the connection WCFManager.CloseConnection(accountBillingServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountBillingServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = invoice; return(jsonNetResult); }
public JsonNetResult GetInvoiceHistory_ByDateRange_Last(int itemLimit, string accountId, string endingBefore, string startDate, string endDate) { var user = AuthenticationCookieManager.GetAuthenticationCookie(); List <Invoice> invoices = null; #region (Plan A) Get data from Redis Cache /* * try * { * IDatabase cache = CoreServiceSettings.RedisConnectionMultiplexers.AccountManager_Multiplexer.GetDatabase(); * * string hashKey = "accountbyid:" + accountId.ToString().Replace("-", ""); * string hashField = "creditcard"; * * var redisValue = cache.HashGet(hashKey, hashField); * * if (redisValue.HasValue) * { * accountCreditCardInfo = JsonConvert.DeserializeObject<AccountCreditCardInfo>(redisValue); * } * } * catch (Exception e) * { * var error = e.Message; * //TODO: Log: error message for Redis call * }*/ #endregion if (invoices == null) { #region (Plan B) Get data from WCF var accountBillingServiceClient = new AccountBillingService.AccountBillingServiceClient(); try { accountBillingServiceClient.Open(); invoices = accountBillingServiceClient.GetInvoiceHistory_ByDateRange_Last( itemLimit, endingBefore, Convert.ToDateTime(startDate).ToUniversalTime(), //<-- We must convert to UTC to get accurrate results Convert.ToDateTime(endDate).ToUniversalTime().AddDays(1), //<-- We must convert to UTC to get accurrate results (We add 1 day to end dates to also get resuts from this day and not just up to midnight the night before) accountId, Common.SharedClientKey ).ToList(); //, //user.Id, //PlatformAdminSite.AccountManagementService.RequesterType.PlatformUser).ToList(); //Close the connection WCFManager.CloseConnection(accountBillingServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountBillingServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = invoices; return(jsonNetResult); }