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 TryRecheckYodlee(int umi) { var mp = _customerMarketplaces.Get(umi); var yodleeMain = new YodleeMain(); var yodleeAccount = _yodleeAccountsRepository.Search(mp.Customer.Id); if (yodleeAccount == null) { return(View(new { error = "Yodlee Account was not found" })); } var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData); long itemId = securityInfo.ItemId; var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); if (lu == null) { return(View(new { error = "Error Loging to Yodlee Account" })); } if (!yodleeMain.IsMFA(itemId)) { bool isRefreshed; try { isRefreshed = yodleeMain.RefreshNotMFAItem(itemId); } catch (RefreshYodleeException ex) { Log.Warn(ex, "TryRecheckYodlee exception"); return(View(new { error = ex.ToString() })); } if (isRefreshed) { var customer = mp.Customer; m_oServiceClient.Instance.UpdateMarketplace(customer.Id, umi, true, _context.UserId); return(View(new { success = true })); } return(View(new { error = "Account wasn't refreshed successfully" })); } //MFA Account for testing redirecting to Yodlee LAW var callback = Url.Action("YodleeCallback", "YodleeRecheck", new { Area = "Underwriter" }, "https") + "/" + umi; string finalUrl = yodleeMain.GetEditAccountUrl(securityInfo.ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); return(Redirect(finalUrl)); } // TryRecheckYodlee