public BankAccountVerifyResult VerifyAccount(BankAccountVerification bv)
        {
            BankAccount     acct = unitOfWork.BankAccounts.Get(bv.BankAccountId);
            ApplicationUser user = accountManager.GetUserByIdAsync(acct.UserId).Result;

            BankAccountVerifyResult result = new BankAccountVerifyResult();

            var options = new BankAccountVerifyOptions
            {
                AmountOne = bv.Deposit1,
                AmountTwo = bv.Deposit2,
            };

            var service = new BankAccountService();
            CustomerBankAccount bankAccount = service.Verify(
                user.StripeIdCustomer,
                acct.StripeIdBankAccount,
                options
                );


            result.IsVerified = bankAccount.Status == StripeStatuses.verified ? true : false;

            return(result);
        }
        internal async Task <Mandate> CreateMandateFor(
            Creditor creditor,
            Customer customer,
            CustomerBankAccount customerBankAccount)
        {
            var request = new CreateMandateRequest
            {
                Links = new CreateMandateLinks
                {
                    Creditor            = creditor.Id,
                    CustomerBankAccount = customerBankAccount.Id
                },
                Metadata = new Dictionary <string, string>
                {
                    ["Key1"] = "Value1",
                    ["Key2"] = "Value2",
                    ["Key3"] = "Value3",
                },
                Scheme = Scheme.Bacs
            };

            var mandatesClient = new MandatesClient(_clientConfiguration);

            return((await mandatesClient.CreateAsync(request)).Item);
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomerBankAccount customerBankAccount = db.CustomerBankAccounts.Find(id);

            db.CustomerBankAccounts.Remove(customerBankAccount);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task OneTimeSetup()
        {
            _creditor = await _resourceFactory.Creditor();

            _customer = await _resourceFactory.CreateLocalCustomer();

            _customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(_customer);
        }
        public async Task <bool> IsPaymentSuccess(string userName, float orderPrice)
        {
            CustomerBankAccount accountBalance = await Entities.FirstAsync(x => x.UserName == userName);

            if (orderPrice <= accountBalance.AccountBalance)
            {
                return(true);
            }
            throw new ArgumentException("You have insufficient funds on your bank account!");
        }
        public async Task OneTimeSetup()
        {
            _creditor = await _resourceFactory.Creditor();

            var customer = await _resourceFactory.CreateLocalCustomer();

            _customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            _mandate = await _resourceFactory.CreateMandateFor(_creditor, customer, _customerBankAccount);
        }
Example #7
0
        public void BankAccountIdSetGetTest()
        {
            //Arrange
            ICustomerBankAccount customerBankAccount = new CustomerBankAccount();
            int expectedBankAccountId = 1;

            //Act
            customerBankAccount.BankAccountId = expectedBankAccountId;

            //Assert
            Assert.Equal(expectedBankAccountId, customerBankAccount.BankAccountId);
        }
Example #8
0
        public void CustomerSetGetTest()
        {
            //Arrange
            ICustomerBankAccount customerBankAccount = new CustomerBankAccount();
            Customer             expectedCustomer    = new Customer();

            //Act
            customerBankAccount.Customer = expectedCustomer;

            //Assert
            Assert.Equal(expectedCustomer, customerBankAccount.Customer);
        }
Example #9
0
        public void BankAccountSetGetTest()
        {
            //Arrange
            ICustomerBankAccount customerBankAccount = new CustomerBankAccount();
            BankAccount          expectedBankAccount = new BankAccount();

            //Act
            customerBankAccount.BankAccount = expectedBankAccount;

            //Assert
            Assert.Equal(expectedBankAccount, customerBankAccount.BankAccount);
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "ID,NameOnCard,CardNumber,CVV,ExpiryDate")] CustomerBankAccount customerBankAccount)
 {
     if (ModelState.IsValid)
     {
         customerBankAccount.CustomerID      = custid;
         customerBankAccount.UserName        = User.Identity.Name;
         db.Entry(customerBankAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "CustomerBankAccounts", new { id = customerBankAccount.ID }));
     }
     //ViewBag.CustomerID = new SelectList(db.Customers, "Id", "FirstName", customerBankAccount.CustomerID);
     return(View(customerBankAccount));
 }
Example #11
0
        public ActionResult Create([Bind(Include = "ID,NameOnCard,CardNumber,CVV,ExpiryDate,CustomerID")] CustomerBankAccount customerBankAccount)
        {
            customerBankAccount.CustomerID = Accid.GetValueOrDefault();
            if (ModelState.IsValid)
            {
                customerBankAccount.UserName = User.Identity.Name;
                db.CustomerBankAccounts.Add(customerBankAccount);
                db.SaveChanges();
                return(RedirectToAction("Details", "Customers", new { id = Accid }));
            }
            if (Spam.spamflag == 1)
            {
                return(RedirectToAction("Index"));
            }

            //ViewBag.CustomerID = new SelectList(db.Customers, "Id", "FirstName", customerBankAccount.CustomerID);
            return(View(customerBankAccount));
        }
Example #12
0
        // GET: CustomerBankAccounts/Details/5
        public ActionResult Details(int?id)
        {
            var cust = db.Customers.Single(c => c.EmailId == User.Identity.Name);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerBankAccount customerBankAccount = db.CustomerBankAccounts.Find(id);

            if (customerBankAccount.CustomerID != cust.Id)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (customerBankAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(customerBankAccount));
        }
Example #13
0
        /// <summary>
        /// 银行账号
        /// </summary>
        /// <returns></returns>
        public ActionResult BankAccount()
        {
            try
            {
                var customerId = CustomerId();
                ViewData["CustomerName"]         = CustomerName();
                ViewData["WeixinUser"]           = WeiXinUser();
                ViewData["CustomerBankAccounts"] = CustomerBankAccount.FindByList(customerId: customerId);

                ViewData["AccountTypes"] = DictionaryBase.FindByList(ancestorId: ConstValue.Catalog.AccountTypeId,
                                                                     isParent: true);
                ViewData["Banks"] = DictionaryBase.FindByList(ancestorId: ConstValue.Catalog.BankId,
                                                              isParent: true);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger().Error(ex);
            }
            return(View());
        }
Example #14
0
        public ActionResult Edit(int?id)
        {
            var cust = db.Customers.Single(c => c.EmailId == User.Identity.Name);

            custid = cust.Id;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerBankAccount customerBankAccount = db.CustomerBankAccounts.Find(id);

            if (customerBankAccount.CustomerID != cust.Id)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (customerBankAccount == null)
            {
                return(HttpNotFound());
            }

            //ViewBag.CustomerID = new SelectList(db.Customers, "Id", "FirstName", customerBankAccount.CustomerID);
            return(View(customerBankAccount));
        }