public PlaidClientTest() { VerifierSettings.DisableClipboard(); VerifierSettings.ScrubLinesContaining(StringComparison.OrdinalIgnoreCase, "RequestId"); VerifierSettings.UseStrictJson(); var configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .AddJsonFile("secrets.json", optional: true) .Build(); var plaidOptions = configuration.GetSection(PlaidOptions.SectionKey).Get <PlaidOptions>(); if (string.IsNullOrWhiteSpace(plaidOptions?.ClientId)) { throw new InvalidOperationException("Please provide ClientId configuration via PLAID__CLIENTID environment variable or Plaid:ClientId in secrets.json."); } if (string.IsNullOrWhiteSpace(plaidOptions?.Secret)) { throw new InvalidOperationException("Please provide Secret configuration via PLAID__SECRET or Plaid:Secret in secrets.json."); } if (string.IsNullOrWhiteSpace(plaidOptions?.DefaultAccessToken)) { throw new InvalidOperationException("Please provide DefaultAccessToken configuration via PLAID__DEFAULTACCESSTOKEN or Plaid:DefaultAccessToken in secrets.json."); } PlaidClient = new PlaidClient( MOptions.Create(plaidOptions)); }
public void FetchInstitutionsAsync_should_retrieve_a_list_of_500_banks() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Institution.GetRequest() { Offset = 0, Count = 500, Options = new Institution.GetOptions { IncludeOptionalMetadata = true } }.UseDefaults(); var result = sut.FetchInstitutionsAsync(request).Result; // Assert result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.Institutions.Length.ShouldBe(500); result.Institutions.Where(i => i.Logo != null).ShouldNotBeEmpty(); foreach (var i in result.Institutions) { i.Url.ShouldNotBeNullOrEmpty(); } }
public Plaid(Controller controller) { Controller = controller; Client = new PlaidClient(System.Environment.GetEnvironmentVariable("PLAID_SANDBOX_CLIENT_ID"), System.Environment.GetEnvironmentVariable("PLAID_SANDBOX_SECRET"), System.Environment.GetEnvironmentVariable("PLAID_SANDBOX_ACCESS_TOKEN"), Acklann.Plaid.Environment.Sandbox); }
public async void GetByIdTest() { const string clientId = "5e4c1c52b83f3800124fc525"; const string clientSecret = "93c8b61ef98301c4bac73677b8be73"; const string publicKey = "ef0d740aef5ab5b25d094ad150ed05"; var client = new PlaidClient(Environment.Sandbox); var institutionRequest = new GetRequest() { Count = 1, Offset = 0, ClientId = clientId, Secret = clientSecret }; var institutionResults = await client.FetchAllInstitutionsAsync(institutionRequest); Assert.Null(institutionResults.Exception); Assert.True(institutionResults.IsSuccessStatusCode); Assert.True(institutionResults.Institutions.Length == 1); var idRequest = new SearchByIdRequest() { PublicKey = publicKey, InstitutionId = institutionResults.Institutions.FirstOrDefault()?.Id }; var idResults = await client.FetchInstitutionByIdAsync(idRequest); Assert.Null(idResults.Exception); Assert.True(idResults.IsSuccessStatusCode); Assert.NotNull(idResults.Institution); }
public void Can_create_link_token() { // Arrange var sut = new PlaidClient(Environment.Sandbox); var request = new Management.CreateLinkTokenRequest() { ClientName = "Example Client Name", Language = "en", CountryCodes = new string[] { "US" }, User = new Management.CreateLinkTokenRequest.UserInfo { ClientUserId = Guid.NewGuid().ToString() }, Products = new string[] { "auth" } }.UseDefaultsWithNoAccessToken(); // Act var result = sut.CreateLinkToken(request).Result; // Assert result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.LinkToken.ShouldNotBeNullOrEmpty(); result.Expiration.ShouldNotBeNullOrEmpty(); }
public void Can_get_account_holder_information() { // Arrange var sut = new PlaidClient(Environment.Sandbox); var request = new Identity.GetUserIdentityRequest().UseDefaults(); // Act var result = sut.FetchUserIdentityAsync(request).Result; bool publicKeyDontHaveAccess = result.Exception?.ErrorCode == Exceptions.ErrorCode.InvalidProduct; if (publicKeyDontHaveAccess) { Assert.Inconclusive(Helper.your_public_key_do_not_have_access_contact_plaid); } // Assert result.ShouldNotBeNull(); result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.Item.ShouldNotBeNull(); result.Accounts.Length.ShouldBeGreaterThan(0); result.Accounts[0].Owners.ShouldAllBe(x => x.Names.Length > 0); result.Accounts[0].Owners.ShouldAllBe(x => x.Addresses.Length > 0); result.Accounts[0].Owners.ShouldAllBe(x => x.PhoneNumbers.Length > 0); }
public void Can_get_all_institutions() { // Arrange const int limit = 5; var request = new Institution.SearchAllRequest() { Take = limit }; request.CountryCodes = new string[] { "US" }; request.UseDefaults(); var sut = new PlaidClient(Environment.Sandbox); // Act var response1 = sut.FetchAllInstitutionsAsync(request).Result; request.Take = 1; request.Skip = limit; var response2 = sut.FetchAllInstitutionsAsync(request).Result; var page = response1.Institutions.Select(x => x.Id).ToArray(); var nextItem = response2.Institutions.First().Id; // Assert response1.IsSuccessStatusCode.ShouldBeTrue(); response2.IsSuccessStatusCode.ShouldBeTrue(); response1.Institutions.Length.ShouldBe(limit); response2.Institutions.Length.ShouldBe(1); page.ShouldNotContain(nextItem); }
public static async Task <MainViewModel> Create() { string clientId = await ProtectedData.UnprotectStringAsync(ProtectedClientId); string clientSecret = await ProtectedData.UnprotectStringAsync(ProtectedClientSecret); PlaidClient client = new PlaidClient(clientId, clientSecret); return(new MainViewModel(client)); }
public PlaidLinkWindow( PlaidClient plaidClient, IOptionsSnapshot <PlaidTokens> plaidOptions, ILogger <PlaidLinkWindow> logger) { _plaidClient = plaidClient; _plaidOptions = plaidOptions.Value; _logger = logger; InitializeComponent(); }
public Connector(Program.Args args, ConnectorConfig config) { this.args = args; this.config = config; this.plaid = new PlaidClient(Acklann.Plaid.Environment.Development); this.firefly = new TransactionsApi(new FireflyIII.Client.Configuration() { BasePath = config.firefly.url, AccessToken = config.firefly.token, }); }
public IActionResult GetPublicToken(Environment environment) { var client = new PlaidClient(environment); var result = client.CreatePublicTokenAsync(new CreatePublicTokenRequest() { Secret = _credentials.Secret, ClientId = _credentials.ClientId, AccessToken = _credentials.AccessToken, }).Result; System.Diagnostics.Debug.WriteLine($"public_token: '{result.PublicToken}'"); return(Ok(result)); }
public void Can_retrieve_plaid_category_list() { // Arrange var sut = new PlaidClient(Environment.Sandbox); var request = new Category.GetCategoriesRequest().UseDefaults(); // Act var result = sut.FetchCategoriesAsync(request).Result; // Assert result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.Categories.Length.ShouldBeGreaterThan(0); }
public void FetchAccountBalanceAsync_should_retrieve_the_account_balances_of_an_user() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Balance.GetBalanceRequest().UseDefaults(); var result = sut.FetchAccountBalanceAsync(request).Result; // Assert result.RequestId.ShouldNotBeNullOrEmpty(); result.Accounts.Length.ShouldBeGreaterThanOrEqualTo(1); result.Accounts[0].Balance.Current.ShouldBeGreaterThanOrEqualTo(1); }
public async Task CreatePublicTokenAsync_should_retrieve_a_response_from_the_api_server() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; // Act CreatePublicTokenRequest request = new CreatePublicTokenRequest { }; CreatePublicTokenResponse result = await client.CreatePublicTokenAsync(request); // Assert result.Exception.ShouldBeNull(); result.SuccessfulOutcome.ShouldBeTrue(); result.PublicToken.ShouldNotBeNull(); }
public IActionResult GetAccessToken(Environment environment, [FromBody] PlaidLinkResponse metadata) { var client = new PlaidClient(environment); ExchangeTokenResponse result = client.ExchangeTokenAsync(new ExchangeTokenRequest() { Secret = _credentials.Secret, ClientId = _credentials.ClientId, PublicToken = metadata.PublicToken }).Result; _credentials.AccessToken = result.AccessToken; System.Diagnostics.Debug.WriteLine($"access_token: '{result.AccessToken}'"); return(Ok(result)); }
public async System.Threading.Tasks.Task <IActionResult> GetAccessTokenAsync([FromBody] PlaidLinkResponse bank_info) { var client = new PlaidClient(_clientId, _secrets, null, Acklann.Plaid.Environment.Sandbox); ExchangeTokenResponse response = await client.ExchangeTokenAsync(new ExchangeTokenRequest { ClientId = _clientId, Secret = _secrets, PublicToken = bank_info.PublicToken }); UpdateAccessToken(response.AccessToken); return(Json(response)); }
public async Task FetchAccountBalanceAsync_should_retrieve_the_account_balances_of_an_user() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; // Act GetBalanceRequest request = new GetBalanceRequest { }; GetBalanceResponse result = await client.FetchAccountBalanceAsync(request); // Assert result.Request.ShouldNotBeNullOrEmpty(); result.Accounts.Length.ShouldBeGreaterThanOrEqualTo(1); result.Accounts[0].Balance.Current.ShouldBeGreaterThanOrEqualTo(1); }
public static async Task InitializeAsync(TestContext context) { await Helper.InitializeAsync(); if (PlaidClient.DefaultRequestFallbackData.AccessToken is null || PlaidClient.DefaultRequestFallbackData.PublicToken is null) { using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; CreateSandboxedPublicTokenResponse response = await client.CreateSandboxedPublicTokenAsync(new CreateSandboxedPublicTokenRequest { Institution = "ins_14", InitialProducts = new[] { "assets", "auth", /*"balance",*/ "transactions", "income", "identity" } }); PlaidClient.DefaultRequestFallbackData.PublicToken = response.PublicToken; PlaidClient.DefaultRequestFallbackData.AccessToken = (await client.ExchangeTokenAsync(new ExchangeTokenRequest { })).AccessToken; await Helper.PersistCommonEndpointRequestDataAsync(); } }
public async Task FetchCategoriesAsync_should_retrieve_the_api_category_list() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; GetCategoriesRequest request = new GetCategoriesRequest { }; // Act GetCategoriesResponse result = await client.FetchCategoriesAsync(request); // Assert result.SuccessfulOutcome.ShouldBeTrue(); result.Request.ShouldNotBeNullOrEmpty(); result.Categories.Length.ShouldBeGreaterThan(0); }
public void Can_get_bank_account_information() { // Arrange var sut = new PlaidClient(Environment.Sandbox); var request = new Auth.GetAccountInfoRequest().UseDefaults(); // Act var result = sut.FetchAccountInfoAsync(request).Result; // Assert result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.Accounts.Length.ShouldBeGreaterThan(0); (result.Numbers.ACH.Length + result.Numbers.EFT.Length + result.Numbers.International.Length + result.Numbers.BACS.Length).ShouldBeGreaterThan(0); result.Item.ShouldNotBeNull(); }
public void Can_refresh_transactions() { // Arrange var request = new Transactions.RefreshTransactionRequest(); request.UseDefaults(); // Act var sut = new PlaidClient(Environment.Sandbox); var result = sut.RefreshTransactionsAsync(request).Result; // Assert result.ShouldNotBeNull(); result.RequestId.ShouldNotBeNullOrEmpty(); result.IsSuccessStatusCode.ShouldBeTrue(); }
public void Can_exchange_link_token_for_access_token() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Management.ExchangeTokenRequest() { PublicToken = "public-sandbox-5c224a01-8314-4491-a06f-39e193d5cddc" }.UseDefaults(); var result = sut.ExchangeTokenAsync(request).Result; // Assert result.Exception.ShouldNotBeNull(); result.IsSuccessStatusCode.ShouldBeFalse(); }
public async Task FetchInstitutionByIdAsync_should_retrieve_a_bank_that_matches_a_specified_id() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; // Act SearchByIdRequest request = new SearchByIdRequest { Institution = "ins_109511" }; SearchByIdResponse response = await client.FetchInstitutionByIdAsync(request); // Assert response.SuccessfulOutcome.ShouldBeTrue(); response.Request.ShouldNotBeNullOrEmpty(); response.Institution.Identifier.ShouldBe(request.Institution); }
public PlaidAccountsViewModel( AccountService accountService, PlaidClient plaidClient, IOptionsSnapshot <PlaidOptions> plaidOptions, Func <PlaidLinkWindow> newPlaidLinkWindow, ILogger <PlaidAccountsViewModel> logger) { _accountService = accountService; _plaidClient = plaidClient; _items = plaidOptions.Value.AccessTokens; _newPlaidLinkWindow = newPlaidLinkWindow; _logger = logger; PlaidSources = _items.Keys.ToArray(); SelectedPlaidSource = PlaidSources.FirstOrDefault(); }
public async void SearchTest() { const string clientId = "5e4c1c52b83f3800124fc525"; const string clientSecret = "93c8b61ef98301c4bac73677b8be73"; const string publicKey = "ef0d740aef5ab5b25d094ad150ed05"; var client = new PlaidClient(Environment.Sandbox); var institutionRequest = new SearchByIdRequest() { PublicKey = publicKey, }; var institutionResults = await client.FetchInstitutionsAsync(institutionRequest); Assert.Null(institutionResults.Exception); Assert.True(institutionResults.Institutions.Length == 10); }
public void ExchangePublicTokenAsync_should_retrieve_a_response_from_the_api_server() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Management.ExchangeTokenRequest() { PublicToken = "public-sandbox-5c224a01-8314-4491-a06f-39e193d5cddc" }.UseDefaults(); var result = sut.ExchangeTokenAsync(request).Result; // Assert result.Exception.ShouldNotBeNull(); result.IsSuccessStatusCode.ShouldBeFalse(); }
public void FetchTransactionsAsync_should_retrieve_a_list_of_transactions() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Transactions.GetTransactionsRequest().UseDefaults(); var result = sut.FetchTransactionsAsync(request).Result; // Assert result.IsSuccessStatusCode.ShouldBeTrue(); result.RequestId.ShouldNotBeNullOrEmpty(); result.TransactionsReturned.ShouldBeGreaterThan(0); result.Transactions.Length.ShouldBeGreaterThan(0); result.Transactions[0].Amount.ShouldBeGreaterThan(0); }
public void FetchInstitutionByIdAsync_should_retrieve_a_bank_that_matches_a_specified_id() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Institution.SearchByIdRequest() { InstitutionId = "ins_109511" }.UseDefaults(); var response = sut.FetchInstitutionByIdAsync(request).Result; // Assert response.IsSuccessStatusCode.ShouldBeTrue(); response.RequestId.ShouldNotBeNullOrEmpty(); response.Institution.Id.ShouldBe(request.InstitutionId); }
public void Can_retrieve_liabilities() { // Arrange var sut = new PlaidClient(Environment.Sandbox); // Act var request = new Liabilities.GetLiabilitiesRequest().UseDefaults(); var result = sut.FetchLiabilitiesAsync(request).Result; // Assert result.RequestId.ShouldNotBeNullOrEmpty(); result.Accounts.Length.ShouldBeGreaterThanOrEqualTo(1); result.Accounts[0].Balance.Current.ShouldBeGreaterThanOrEqualTo(1); result.Liabilities.Credit.ShouldNotBeNull(); result.Liabilities.Mortgage.ShouldNotBeNull(); result.Liabilities.Student.ShouldNotBeNull(); }
// ==================== Investments ==================== // //[TestMethod] public void Can_get_investment_holdings() { // Arrange var request = new Investments.GetInvestmentHoldingsRequest(); request.UseDefaults(); var sut = new PlaidClient(Environment.Sandbox); // Act var result = sut.FetchInvestmentHoldingsAsync(request).Result; // Assert result.ShouldNotBeNull(); result.IsSuccessStatusCode.ShouldBeTrue(); result.Holdings.ShouldNotBeNull(); }