public ExternalAccountServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new ExternalAccountService(this.StripeClient); this.createOptions = new ExternalAccountCreateOptions { ExternalAccount = "btok_123", }; this.updateOptions = new ExternalAccountUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, Name = "Jenny Rosen", }; this.listOptions = new ExternalAccountListOptions { Limit = 1, }; }
public ExternalAccountServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new ExternalAccountService(); this.createOptions = new ExternalAccountCreateOptions { ExternalAccountBankAccount = new AccountBankAccountOptions { AccountNumber = "000123456789", Country = "US", Currency = "usd", RoutingNumber = "110000000", } }; this.updateOptions = new ExternalAccountUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new ExternalAccountListOptions { Limit = 1, }; }
public CardService(IServiceProvider serviceProvider, global::Stripe.CardService cardService, ExternalAccountService externalAccountService) : base(serviceProvider) { _cardService = cardService; _externalAccountService = externalAccountService; _accountCards = UnitOfWork.RepositoryAsync <AccountCard>(); _customerCards = UnitOfWork.RepositoryAsync <CustomerCard>(); }
/// <inheritdoc /> /// <exception cref="UserNotFoundException">Thrown when the user is not found</exception> public async Task <BankAccountViewModel> AddBankAccount(AddBankAccountBody addBankAccountBody) { var user = await ApplicationContext.Users.Include(x => x.BankAccounts) .FirstOrDefaultAsync(x => x.Id == addBankAccountBody.UserId); if (user == null) { throw new UserNotFoundException(); } if (user.StripeAccountId == null) { var account = CreateAccount(user); user.StripeAccountId = account.Id; await ApplicationContext.SaveChangesAsync(); } var options = new ExternalAccountCreateOptions() { ExternalAccount = addBankAccountBody.BankToken }; var service = new ExternalAccountService(); try { // request create bank account from the Stripe api var bank = (Stripe.BankAccount)service.Create(user.StripeAccountId, options); // create bank account using Stripe response var bankAccount = new BankAccount { StripeBankAccountId = bank.Id, Bank = bank.BankName, Country = bank.Country, Currency = bank.Currency, Name = bank.AccountHolderName, LastFour = bank.Last4 }; user.BankAccounts = new List <BankAccount> { bankAccount }; await ApplicationContext.SaveChangesAsync(); return(Mapper.Map <BankAccountViewModel>(user.BankAccounts[0])); } catch { Logger.LogWarning("Failed to save bank account"); throw; } }
public ExternalAccountServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new ExternalAccountService(); this.createOptions = new ExternalAccountCreateOptions { ExternalAccountTokenId = "btok_123", }; this.updateOptions = new ExternalAccountUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new ExternalAccountListOptions { Limit = 1, }; }
public void CreateAccount(string firstName, string lastName, string email) { StripeConfiguration.ApiKey = secretkey; var options = new TokenCreateOptions { BankAccount = new BankAccountOptions { Country = "CA", Currency = "cad", AccountHolderName = $"{firstName} {lastName}", AccountHolderType = "individual", RoutingNumber = "11000-000", AccountNumber = "000123456789" } }; var service = new TokenService(); var stripeToken = service.Create(options); Console.WriteLine("------------------------------------------------------------------"); Console.WriteLine($"Bank token: {stripeToken.Id}"); //create account var accountOptions = new AccountCreateOptions { Type = "custom", Country = "CA", DefaultCurrency = "cad", Individual = new PersonCreateOptions { Address = new AddressOptions { City = "Cumberland", Line1 = "1 Cumberland Square", PostalCode = "K4C", State = "Ontario" }, FirstName = firstName, LastName = lastName, Dob = new DobOptions { Year = 1989, Month = 1, Day = 1 }, IdNumber = "123456789",//SIN Email = email }, Email = email, TosAcceptance = new AccountTosAcceptanceOptions { Date = DateTime.Now, Ip = stripeToken.ClientIp }, BusinessType = "individual", Settings = new AccountSettingsOptions { Payouts = new AccountSettingsPayoutsOptions { DebitNegativeBalances = true, Schedule = new AccountSettingsPayoutsScheduleOptions { Interval = "daily" } } }, RequestedCapabilities = new List <string> { "card_payments", "transfers", }, }; var accountService = new AccountService(); var account = accountService.Create(accountOptions); Console.WriteLine("------------------------------------------------------------------"); Console.WriteLine($"Account: {account.Id}"); //create external account var externalOption = new ExternalAccountCreateOptions { ExternalAccount = stripeToken.Id, DefaultForCurrency = true }; var externalAccountService = new ExternalAccountService(); var externalAccount = externalAccountService.Create(account.Id, externalOption); Console.WriteLine("------------------------------------------------------------------"); Console.WriteLine($"External Account: {externalAccount.Id}"); }
public async void RegisterUser(Object sender, EventArgs e) { try { string firstNameVar = firstName.Text; string lastNameVar = lastName.Text; int dobDayVar = Convert.ToInt32(dobDay.Text); int dobMonthVar = Convert.ToInt32(dobMonth.Text); int dobYearVar = Convert.ToInt32(dobYear.Text); string addressLine1Var = addressLine1.Text; string addressLine2Var = addressLine2.Text; string postalCodeVar = postalCode.Text; var statesPickerVar = statesPicker.Items[statesPicker.SelectedIndex]; string routingNumberVar = routingNumber.Text; string accountNumberVar = accountNumber.Text; string cityVar = city.Text; StripeConfiguration.SetApiKey("sk_test_Q5wSnyXL03yN0KpPaAMYttOb"); //-------Get IP Address---------// var MyIp = ""; string uploadId = ""; foreach (IPAddress adress in Dns.GetHostAddresses(Dns.GetHostName())) { MyIp = adress.ToString(); break; } //------Camera will Open User take the Picture Of Idenity Card-----------// /* var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions * { * Directory = "Sample", * Name = "test.jpg", * PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small * * }); * * //-------Upload File in stripe and return the file Id -------------// * using (FileStream stream = System.IO.File.Open(file.Path, FileMode.Open)) * { * var fileService = new FileService(); * var fileCreateOptions = new FileCreateOptions * { * File = stream, * Purpose = "identity_document", * }; * Stripe.File upload = fileService.Create(fileCreateOptions); * uploadId = upload.Id; * } */ //------Set File.id-----/// AccountVerificationOptions verifiy = new AccountVerificationOptions { DocumentId = uploadId, }; //--------Create User Account Legal Entity-----------// AccountLegalEntityOptions legalEntity = new AccountLegalEntityOptions { FirstName = firstNameVar, LastName = lastNameVar, Address = new AddressOptions { City = cityVar, Country = "AU", PostalCode = postalCodeVar, Line1 = addressLine1Var, Line2 = addressLine2Var, State = statesPickerVar }, Dob = new AccountDobOptions { Day = dobDayVar, Month = dobMonthVar, Year = dobYearVar }, Type = "individual", Verification = verifiy, PhoneNumber = "+611234567"//Convert.ToString(Xamarin.Forms.Application.Current.Properties["phoneNumber"]) }; //--------Create Payout Account-----------// var options = new AccountCreateOptions { Email = "*****@*****.**", Type = AccountType.Custom, Country = "AU", LegalEntity = legalEntity }; var services = new AccountService(); Account account = services.Create(options); //---------Create External Bank Account and return Token---------/// TokenCreateOptions optionss = new TokenCreateOptions { BankAccount = new BankAccountOptions { Country = "AU", AccountNumber = accountNumberVar, RoutingNumber = routingNumberVar, Currency = "aud" } }; TokenService service = new TokenService(); Token stripeToken = service.Create(optionss); var externalOption = new ExternalAccountCreateOptions { ExternalAccountTokenId = stripeToken.Id, //pass the bank account creation token }; var externalAccount = new ExternalAccountService(); var bankAccount = externalAccount.Create(account.Id, externalOption); //Bank Account Created // await DisplayAlert("", "" + account.Id, "Ok"); //api.AcceptedStripeAgreement(account.Id,CurrentTimeMillis(), MyIp); //Accepted Stripe TOS await DisplayAlert("", "" + account.Id, "Ok"); }catch (Exception ex) { await DisplayAlert("", "" + ex, "Ok"); } }