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 listing_cards_on_customer() { var customerService = new StripeCustomerService(Cache.ApiKey); var bankAccountService = new BankAccountService(Cache.ApiKey); var cardService = new StripeCardService(Cache.ApiKey); var CustomerCreateOptions = new StripeCustomerCreateOptions { Email = "*****@*****.**", SourceToken = "tok_visa", }; var Customer = customerService.Create(CustomerCreateOptions); var BankAccountCreateOptions = new BankAccountCreateOptions { SourceBankAccount = new SourceBankAccount() { RoutingNumber = "110000000", AccountNumber = "000123456789", Country = "US", Currency = "usd", AccountHolderName = "Jenny Rosen", AccountHolderType = BankAccountHolderType.Individual, } }; var BankAccount = bankAccountService.Create(Customer.Id, BankAccountCreateOptions); ListCards = cardService.List(Customer.Id); }
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 AccountPaymentMethod CreateBankAccountPaymentMethod(string accountHolderName, string accountHolderType, string routingNumber, string accountNumber, byte usedFor) { try { var tokenOptions = new TokenCreateOptions { BankAccount = new BankAccountOptions { Country = "US", Currency = "usd", AccountHolderName = accountHolderName, AccountHolderType = accountHolderType, RoutingNumber = routingNumber, AccountNumber = accountNumber } }; var tokenService = new TokenService(); Token token = tokenService.Create(tokenOptions); var stripeCustomer = GetStripeCustomer(); var bankAccountOptions = new BankAccountCreateOptions { Source = token.Id, }; var bankAccountService = new BankAccountService(); BankAccount bankAccount = bankAccountService.Create(stripeCustomer.Id, bankAccountOptions); using (FlyJetsDbContext dbContext = new FlyJetsDbContext(_config)) { var paymentMehtod = new AccountPaymentMethod() { Id = Guid.NewGuid(), AccountId = _accountId, PaymentMethod = (byte)PaymentMethods.BankTransfer, TokenId = token.Id, BankName = token.BankAccount.BankName, RoutingNumber = token.BankAccount.RoutingNumber, HolderName = token.BankAccount.AccountHolderName, AccountLast4 = token.BankAccount.Last4, UsedFor = usedFor, ReferencePaymentMethodId = bankAccount.Id, CreatedOn = DateTime.UtcNow }; dbContext.AccountPaymentMethods.Add(paymentMehtod); dbContext.SaveChanges(); return(paymentMehtod); } } catch (StripeException e) { switch (e.StripeError.ErrorType) { case "card_error": break; case "api_connection_error": break; case "api_error": break; case "authentication_error": break; case "invalid_request_error": break; case "rate_limit_error": break; case "validation_error": break; default: break; } return(null); } }
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); } }