public JsonResult UploadAccounts() { var oEsi = new YodleeServiceInfo(); var yodlees = new List <YodleeAccountModel>(); foreach (var marketplace in this.customer.CustomerMarketPlaces.Where(mp => mp.Marketplace.InternalId == oEsi.InternalId && mp.DisplayName != "ParsedBank")) { yodlees.Add(YodleeAccountModel.ToModel(marketplace)); } var companyFilesSI = new CompanyFilesServiceInfo(); bool hasCompanyFilesMp = this.customer.CustomerMarketPlaces.Any(mp => mp.Marketplace.InternalId == companyFilesSI.InternalId); if (hasCompanyFilesMp) { var companyFiles = this.companyFilesMetaDataRepository.GetBankStatementFiles(this.customer.Id) .ToList(); yodlees.AddRange(companyFiles.Select(x => new YodleeAccountModel { displayName = x })); } return(Json(yodlees, JsonRequestBehavior.AllowGet)); }
public ActionResult RefreshYodlee(string displayName = null) { var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); var yodleeMain = new YodleeMain(); var oEsi = new YodleeServiceInfo(); var yodlees = this.customer.CustomerMarketPlaces .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId) .ToList(); if (yodlees.Count == 0) { return(View(new { error = "Error loading bank accounts" })); } var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); if (lu == null) { return(View(new { error = "Error logging to yodlee account" })); } MP_CustomerMarketPlace umi = displayName == null ? yodlees[0] : yodlees.FirstOrDefault(y => y.DisplayName == displayName); //TODO Currently refreshes the first one if (umi == null) { return(View(new { error = "Account not found" })); } var callback = Url.Action("RecheckYodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https") + "/" + umi.Id; string finalUrl = yodleeMain.GetEditAccountUrl(Serialized.Deserialize <YodleeSecurityInfo>(umi.SecurityData).ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); return(Redirect(finalUrl)); }
public ActionResult AttachYodlee(int csId, string bankName) { try { var oEsi = new YodleeServiceInfo(); this.mpChecker.Check(oEsi.InternalId, this.customer, csId); } catch (MarketPlaceAddedByThisCustomerException e) { Log.Debug(e); return(View((object)DbStrings.AccountAddedByYou)); } var yodleeMain = new YodleeMain(); var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); if (yodleeAccount == null) { YodleeBanks bank = this.yodleeBanksRepository.Search(csId); yodleeAccount = YodleeAccountPool.GetAccount(this.customer, bank); } var callback = Url.Action("YodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https"); string finalUrl = yodleeMain.GetAddAccountUrl(csId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); Log.InfoFormat("Redirecting to yodlee: {0}", finalUrl); return(Redirect(finalUrl)); }
public ViewResult YodleeCallback() { Log.InfoFormat("Got to yodlee's callback with params:{0}", HttpContext.Request.Params); foreach (string key in HttpContext.Request.Params.Keys) { if (key == "oauth_error_code") { Log.WarnFormat("Yodlee returned an error. oauth_error_code:{0} oauth_error_problem:{1}", HttpContext.Request.Params["oauth_error_code"], HttpContext.Request.Params["oauth_error_problem"]); if (HttpContext.Request.Params["oauth_error_code"] == "407") { return(View(new { error = "Failure linking account" })); } } } var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); string decryptedPassword = Encrypted.Decrypt(yodleeAccount.Password); string displayname; long csId; var yodleeMain = new YodleeMain(); var oEsi = new YodleeServiceInfo(); var items = this.customer.CustomerMarketPlaces .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId) .Select(mp => Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData).ItemId).ToList(); long itemId = yodleeMain.GetItemId(yodleeAccount.Username, decryptedPassword, items, out displayname, out csId); if (itemId == -1) { return(View(new { error = "Failure linking account" })); } int marketPlaceId = this.mpTypes .GetAll() .First(a => a.InternalId == oEsi.InternalId) .Id; var securityData = new YodleeSecurityInfo { ItemId = itemId, Name = yodleeAccount.Username, Password = yodleeAccount.Password, MarketplaceId = marketPlaceId, CsId = csId }; var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace(); var marketPlace = this.dbHelper.SaveOrUpdateCustomerMarketplace(displayname, yodleeDatabaseMarketPlace, securityData, this.customer); Log.InfoFormat("Added or updated yodlee marketplace: {0}", marketPlace.Id); this.serviceClient.Instance.UpdateMarketplace(this.context.Customer.Id, marketPlace.Id, true, this.context.UserId); return(View(YodleeAccountModel.ToModel(marketPlace, this.yodleeBanksRepository))); }
public static IEnumerable <SimpleMarketPlaceModel> GetYodleeAccounts(this Customer customer) { var yodleeServiceInfo = new YodleeServiceInfo(); var marketplaces = customer.CustomerMarketPlaces.Where(m => m.Marketplace.InternalId == yodleeServiceInfo.InternalId); var simpleMarketPlaceModels = marketplaces.Select(m => new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = m.Marketplace.Name }); return(simpleMarketPlaceModels); }
public JsonResult Accounts() { var oEsi = new YodleeServiceInfo(); var yodlees = new List <YodleeAccountModel>(); foreach (var marketplace in this.customer.CustomerMarketPlaces.Where(mp => mp.Marketplace.InternalId == oEsi.InternalId && mp.DisplayName != "ParsedBank")) { yodlees.Add(YodleeAccountModel.ToModel(marketplace, this.yodleeBanksRepository)); } return(Json(yodlees, JsonRequestBehavior.AllowGet)); }
public void Check(Customer customer, string accountNumber, string sortcode, string bankAccountType) { if (customer.IsOffline.HasValue && !customer.IsOffline.Value) { return; } if (customer.IsTest) { return; } var yodleeServiceInfo = new YodleeServiceInfo(); var yodleeMps = customer.CustomerMarketPlaces .Where(m => m.Marketplace.InternalId == yodleeServiceInfo.InternalId && m.DisplayName != "ParsedBank").ToList(); if (!yodleeMps.Any()) { return; } var yodleeAcounts = yodleeMps .SelectMany(x => x.YodleeOrders) .SelectMany(o => o.OrderItems) .Select(i => new YodleeAccount { AccountNumber = i.accountNumber, RoutingNumber = i.routingNumber }); foreach (var account in yodleeAcounts) { Log.DebugFormat("AccountNumber {0} SortCode {1} Yodlee Account {2} Yodlee Routing Number {3}", accountNumber, sortcode, account.AccountNumber, account.RoutingNumber); if (string.IsNullOrEmpty(account.AccountNumber)) { continue; } var number = account.AccountNumber.Replace("x", "").Replace(" ", ""); //var routing = account.RoutingNumber.Replace("-", "").Replace(" ", ""); if (accountNumber.Contains(number)) { return; } } throw new YodleeAccountNotFoundException(); }
public JsonResult ParseYodlee(int customerId, int fileId) { var file = m_oServiceClient.Instance.GetCompanyFile(_context.UserId, fileId); var fileMetaData = _companyFiles.Get(fileId); var parser = new TransactionsParser(); var parsed = parser.ParseFile(fileMetaData.FileName, file); if (!string.IsNullOrEmpty(parsed.Error)) { return(Json(new { error = parsed.Error })); } if (parsed.NumOfTransactions == 0) { return(Json(new { error = "File contains 0 transactions" })); } var customer = _customers.Get(customerId); var yodlee = new YodleeServiceInfo(); var yodleeMp = customer.CustomerMarketPlaces.FirstOrDefault(mp => mp.Marketplace.InternalId == yodlee.InternalId && mp.DisplayName == "ParsedBank"); if (yodleeMp != null) { var data = Serialized.Deserialize <YodleeSecurityInfo>(yodleeMp.SecurityData); data.ItemId = fileId; yodleeMp.SecurityData = new Serialized(data); _session.Flush(); m_oServiceClient.Instance.UpdateMarketplace(customer.Id, yodleeMp.Id, false, _context.UserId); } else { int marketPlaceId = _mpTypes.GetAll().First(a => a.InternalId == yodlee.InternalId).Id; var securityData = new YodleeSecurityInfo { ItemId = fileId, Name = "", Password = "", MarketplaceId = marketPlaceId, CsId = 0 }; var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace(); var mp = _helper.SaveOrUpdateCustomerMarketplace("ParsedBank", yodleeDatabaseMarketPlace, securityData, customer); m_oServiceClient.Instance.UpdateMarketplace(customer.Id, mp.Id, false, _context.UserId); } // if return(Json(new { })); } // ParseYodlee
public static IEnumerable <SimpleMarketPlaceModel> GetMarketPlaces(this Customer customer) { var yodlee = new YodleeServiceInfo(); var financialDocuments = new CompanyFilesServiceInfo(); var hmrc = Configuration.Instance.GetVendorInfo("HMRC"); var mps = customer.CustomerMarketPlaces.Where(m => m.Disabled == false); var simpleMps = new List <SimpleMarketPlaceModel>(); foreach (var m in mps) { if (m.Marketplace.InternalId == yodlee.InternalId) { simpleMps.Add(new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = m.DisplayName == "ParsedBank" ? m.Marketplace.Name + "Upload" : m.Marketplace.Name }); } else if (m.Marketplace.InternalId == hmrc.Guid()) { simpleMps.Add(new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = m.DisplayName.Contains("@") ? m.Marketplace.Name + "Upload" : m.Marketplace.Name }); } else if (m.Marketplace.InternalId == financialDocuments.InternalId) { var hasBankStatements = customer.CompanyFiles.Any(x => x.IsBankStatement.HasValue && x.IsBankStatement.Value); var hasCompanyFiles = customer.CompanyFiles.Any(x => !x.IsBankStatement.HasValue || !x.IsBankStatement.Value); if (hasCompanyFiles) { simpleMps.Add(new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = m.Marketplace.Name }); } if (hasBankStatements) { simpleMps.Add(new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = yodlee.DisplayName + "Upload" }); } } else { simpleMps.Add(new SimpleMarketPlaceModel { displayName = m.DisplayName, MpId = m.Marketplace.Id, MpName = m.Marketplace.Name == "Pay Pal" ? "paypal" : m.Marketplace.Name }); } } return(simpleMps); }