public BankAccountServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new BankAccountService(this.StripeClient); this.createOptions = new BankAccountCreateOptions { Source = "btok_123", }; this.updateOptions = new BankAccountUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new BankAccountListOptions { Limit = 1, }; this.verifyOptions = new BankAccountVerifyOptions { Amounts = new List <long> { 32, 45, } }; }
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); }
public static bool VerifyBankAccount(Tenant tenant, List <string> inboundDeposits) { var customer = GetCustomer(tenant.StripeID); List <long> deposits = ValidateDeposits(inboundDeposits); //This may have to be provided by customer. var options = new BankAccountVerifyOptions { Amounts = new List <long>() }; foreach (var deposit in deposits) { options.Amounts.Add(deposit); } var service = new BankAccountService(); try { BankAccount bankAccount = service.Verify( tenant.StripeID, customer.DefaultSourceId, options ); if (bankAccount.Status.ToLower() == "verified") { return(SQL.SQLStatements.UpdateStripeStatus(tenant.TenantID, true)); } else { return(false); } } catch (StripeException ex) { if (ex.Message == "This bank account has already been verified.") { return(SQL.SQLStatements.UpdateStripeStatus(tenant.TenantID, true)); } throw new Exception(ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); } }
public BankAccountServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new BankAccountService(); this.createOptions = new BankAccountCreateOptions { SourceBankAccount = new SourceBankAccount { AccountNumber = "000123456789", Country = "US", Currency = "usd", AccountHolderName = "John Doe", AccountHolderType = BankAccountHolderType.Company, RoutingNumber = "110000000", Metadata = new Dictionary <string, string> { { "key", "value" }, }, } }; this.updateOptions = new BankAccountUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new BankAccountListOptions { Limit = 1, }; this.verifyOptions = new BankAccountVerifyOptions { Amounts = new List <long> { 32, 45, } }; }
public BankAccountServiceTest() { this.service = new BankAccountService(); this.createOptions = new BankAccountCreateOptions { SourceBankAccount = new SourceBankAccount() { AccountNumber = "000123456789", Country = "US", Currency = "usd", AccountHolderName = "John Doe", AccountHolderType = BankAccountHolderType.Company, RoutingNumber = "110000000", Metadata = new Dictionary <string, string> { { "key", "value" }, }, } }; this.updateOptions = new BankAccountUpdateOptions() { Metadata = new Dictionary <string, string>() { { "key", "value" }, }, }; this.listOptions = new BankAccountListOptions() { Limit = 1, }; this.verifyOptions = new BankAccountVerifyOptions { AmountOne = 32, AmountTwo = 45, }; }
public async Task <int> PaymentAch(string bankToken, int amount, string account_number, string rounting_number) { try { // Create an ACH charge StripeConfiguration.SetApiKey(ep.GetStripeSecretKey()); CustomerService customerService = new CustomerService(); var customerOptions = new CustomerCreateOptions { }; Customer achCustomer = customerService.Create(customerOptions); // Create Bank Account var bankAccountOptions = new BankAccountCreateOptions { SourceToken = bankToken }; var bankService = new BankAccountService(); BankAccount bankAccount = bankService.Create(achCustomer.Id, bankAccountOptions); // Verify BankAccount List <long> Amounts = new List <long>(); Amounts.Add(32); Amounts.Add(45); var verifyOptions = new BankAccountVerifyOptions { Amounts = Amounts }; bankAccount = bankService.Verify(achCustomer.Id, bankAccount.Id, verifyOptions); var chargeOptions = new ChargeCreateOptions { Amount = amount, Currency = "usd", Description = "Charge for [email protected]", CustomerId = achCustomer.Id }; var chargeService = new ChargeService(); Charge charge = chargeService.Create(chargeOptions); // Payout from Stripe to Bank Account string bankAccountStr = account_number; // "000123456789"; string bankRoutingStr = rounting_number; // "110000000"; // Get self account var accountOptions = new AccountCreateOptions { Email = "*****@*****.**", Type = AccountType.Custom, Country = "US", ExternalBankAccount = new AccountBankAccountOptions() { Country = "US", Currency = "usd", AccountHolderName = "John Brown",//account_name AccountHolderType = "individual", RoutingNumber = bankRoutingStr, AccountNumber = bankAccountStr }, PayoutSchedule = new AccountPayoutScheduleOptions() { Interval = "daily" }, TosAcceptance = new AccountTosAcceptanceOptions() { Date = DateTime.Now.AddDays(-10), Ip = "202.47.115.80", UserAgent = "Chrome" }, LegalEntity = new AccountLegalEntityOptions() { Dob = new AccountDobOptions() { Day = 1, Month = 4, Year = 1991 }, FirstName = "John", LastName = "Brown", Type = "individual" } }; var accountService = new AccountService(); Account account = await accountService.CreateAsync(accountOptions); StripeConfiguration.SetApiKey(ep.GetStripeSecretKey()); var service = new BalanceService(); Balance balance = await service.GetAsync(); var transOptions = new TransferCreateOptions { Amount = amount, Currency = "usd", Destination = account.Id }; var transferService = new TransferService(); Transfer Transfer = transferService.Create(transOptions); var payoutOptions = new PayoutCreateOptions { Amount = amount, Currency = "usd", Destination = account.ExternalAccounts.First().Id, SourceType = "card", StatementDescriptor = "PAYOUT", //Method = "instant" }; var requestOptions = new RequestOptions(); requestOptions.ApiKey = ep.GetStripeSecretKey(); requestOptions.StripeConnectAccountId = account.Id; var payoutService = new PayoutService(); var payout = await payoutService.CreateAsync(payoutOptions, requestOptions); return(1); } catch (Exception) { return(0); } }