示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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 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
示例#5
0
        public static Dictionary <BankData, List <BankTransactionData> > GetOrders(string userName, string password, long itemId)
        {
            Log.Debug("Begin retrieve yodlee orders");
            var yodlee = new YodleeMain();
            var lu     = yodlee.LoginUser(userName, password);

            if (lu == null)
            {
                Log.Error("Login To Yodlee Account Failed No Data Can Be Retrieved");
                return(null);
            }
            var    displayBankData = new GetBankData();
            string itemSummaryInfo;
            string error;
            Dictionary <BankData, List <BankTransactionData> > orders;

            displayBankData.GetBankDataForItem(yodlee.UserContext, itemId, out itemSummaryInfo, out error, out orders);
            lu.logoutUser(yodlee.UserContext);
            return(orders);
        }