/// <summary> /// Fetch and display user account balances /// </summary> static async Task DisplayAccountBalancesAsync(IBankingConnector bankConnector) { BankingResult <List <Account> > accounts = await bankConnector.GetAccountsAsync(); if (accounts.GetStatus() == ResultStatus.DONE) { Console.WriteLine("Listing user accounts..."); foreach (Account account in accounts.GetData()) { Console.WriteLine($"Account {account.Iban}"); BankingResult <List <Balance> > resultBalances = await bankConnector.GetBalancesAsync(account.Id); if (resultBalances.GetStatus() == ResultStatus.DONE) { List <Balance> accountBalances = resultBalances.GetData(); foreach (Balance balance in accountBalances) { Console.WriteLine($"- {balance.BalanceType}: {balance.BalanceAmount.Currency}{balance.BalanceAmount.Amount} ({balance.ReferenceDate:ddMMMyyyy})"); } } } } }
/// <summary> /// Request Account Access /// /// Manual process: /// You have to go manually to the bankURL, authenticate there and grant the permission to access the account(s) /// The bank will then redirect you, you must copy the query string and put it back in the application to continue /// /// FlowId: /// In this particular case, Crelan ask for a fixed FlowId /// Most of the time, you need to provide a unique identifier /// </summary> static async Task RequestAccountsAccessAsync(IBankingConnector bankConnector) { // Initialize account access request BankingResult <string> bankingResult = await bankConnector.RequestAccountsAccessAsync(new AccountsAccessRequest { FlowId = "STATE", //Guid.NewGuid().ToString() FrequencyPerDay = 2, RedirectUrl = RedirectURL, }); if (bankingResult.GetStatus() == ResultStatus.REDIRECT) { // FlowContext must be reused FlowContext flowContext = bankingResult.GetFlowContext(); // Ask the user to manually go to the redirect URL and enter the result string bankURL = bankingResult.GetData(); Console.WriteLine($"URL: {bankURL}"); Console.Write("Enter code: "); string queryString = Console.ReadLine(); Console.Write(flowContext); // Finalize authentication BankingResult <IUserContext> result = await bankConnector.RequestAccountsAccessFinalizeAsync(flowContext, queryString); if (result.GetStatus() == ResultStatus.DONE) { Console.WriteLine("RequestAccountsAccess succeeded"); return; } } throw new Exception("RequestAccountsAccess failed"); }
static async Task Main(string[] args) { var services = new ServiceCollection(); services.AddBankingSdk(); // Setting general settings of BankingSDk BankSettings generalBankSettings = new BankSettings(); generalBankSettings.NcaId = "VALID_NCA_ID"; string filePath = @"C:\Users\Yassine\Documents\StageEntrainement\BankingSDK - Copie\BankingSDK\Test\TestApp\example_eidas_client_tls.cer"; string filePath2 = @"C:\Users\Yassine\Documents\StageEntrainement\BankingSDK - Copie\BankingSDK\Test\TestApp\example_eidas_client_signing.cer"; generalBankSettings.TlsCertificate = new X509Certificate2(filePath, "banking"); generalBankSettings.SigningCertificate = new X509Certificate2(filePath2, "banking"); SdkApiSettings.CompanyKey = "1df53a2d-26aa-4ef1-9f3c-09a1092e5413"; SdkApiSettings.ApplicationKey = "d7726cbf-e51f-4e0e-a3bb-132913ad8032"; SdkApiSettings.Secret = "W2ANVUVRQS7AKBFCZLKHGLWXCC6FRUGXAV3O3E33H7D1ZULX6ME6UKOKGNKSXPA6LK9YH1JUSR9JI58S0JIEPKCZHSIQ4KF27GPOUWPFDTODKECLP11OG5RBHJRZT20HMHLBPT7D4DB559PCP6BCS1VBZOHKF0VK3G1D2B564XUD4VFH4OJW1YZVVKLBLW8ER0CYIMKOBEH4GSGEI9Q1Q9SERGRSZ3UHZQVDTR9SD4UWQ4ODDH3MGGXSI7GC42ZH"; SdkApiSettings.TppLegalName = "EXTHAND"; SdkApiSettings.IsSandbox = false; //BankingSDK. bankConnector = new Connector(generalBankSettings); BankingSDK.BE.KBC.BeKbcConnector bankConnector = new BeKbcConnector(generalBankSettings); string userId = Guid.NewGuid().ToString(); string userContect = (await bankConnector.RegisterUserAsync(userId)).GetData().ToJson(); string callBackUrl = "https://developer.bankingsdk.com/callback"; AccountsAccessRequest accountsAccessRequest = new AccountsAccessRequest { FlowId = SdkApiSettings.ApplicationKey, FrequencyPerDay = 4, RedirectUrl = callBackUrl, PsuIp = "10.10.10.10", SingleAccount = "BE91732047678076" }; BankingResult <string> bankingResult = await bankConnector.RequestAccountsAccessAsync(accountsAccessRequest); if (bankingResult.GetStatus() == ResultStatus.REDIRECT) { // We get the flow context. var flowContext = bankingResult.GetFlowContext(); string redirectUrlOnTheBank = bankingResult.GetData(); var psi = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"); psi.Arguments = redirectUrlOnTheBank; Process.Start(psi); Console.WriteLine("QueryString received?"); string queryString = Console.ReadLine(); BankingResult <IUserContext> result = await bankConnector.RequestAccountsAccessFinalizeAsync(flowContext, queryString); if (result.GetStatus() == ResultStatus.DONE) { Console.WriteLine("Ok. Cool."); BankingResult <List <Account> > accounts = await bankConnector.GetAccountsAsync(); foreach (Account account in accounts.GetData()) { Console.WriteLine("Account " + account.Iban); BankingResult <List <Balance> > resultBalances = await bankConnector.GetBalancesAsync(account.Iban); if (resultBalances.GetStatus() == ResultStatus.DONE) { List <Balance> accountBalances = resultBalances.GetData(); foreach (Balance balance in accountBalances) { Console.WriteLine(" Balance : " + balance.BalanceAmount + " " + balance.ReferenceDate?.ToString("dd MMM yyyy")); } } } } } Console.ReadLine(); return; }
static async Task Main(string[] args) { var services = new ServiceCollection(); services.AddBankingSdk(); // Setting general settings of BankingSDk BankSettings generalBankSettings = new BankSettings(); generalBankSettings.NcaId = "VALID_NCA_ID"; generalBankSettings.TlsCertificate = new X509Certificate2("ING-eidas_tls.pfx", "bankingsdk"); generalBankSettings.SigningCertificate = new X509Certificate2("ING-eidas_signing.pfx", "bankingsdk"); SdkApiSettings.CompanyKey = "f954a771-509b-43c9-a064-0a3f9c9bb9d3"; SdkApiSettings.ApplicationKey = "4d972ae0-13cf-44ad-a20a-9ff44b884ce7"; SdkApiSettings.Secret = "MMH74H6OCI5CHPX1OS56PI6HSEGAVZ9PU8V8KTXL87ADBB23VJX1OFDDPAOZA53MIPRI4ZQ54T8SI2FRLMPMCIBP5RSKE7LCEX5WTU952164HV5W46NYQQKAOCMNHF07I5NU7T71NTTKLHHJW5QHUWWXN4HQHWYWB9VLHKZK9WL669ZH5D0LZSMVI0HCLQT157JLV5CLGFI7L00OFAVE5N7SW9CRDW9SCUA9ZNV9APEUJPKS936K5P5SA1YV3VIT"; SdkApiSettings.TppLegalName = "EXTHAND"; SdkApiSettings.IsSandbox = true; BankingSDK.BE.ING.BeIngConnector bankConnector = new BeIngConnector(generalBankSettings); //BankingSDK.BE.KBC.BeKbcConnector bankConnector = new BeKbcConnector(generalBankSettings); string userId = Guid.NewGuid().ToString(); string userContect = (await bankConnector.RegisterUserAsync(userId)).GetData().ToJson(); string callBackUrl = "https://developer.bankingsdk.com/callback"; AccountsAccessRequest accountsAccessRequest = new AccountsAccessRequest { FlowId = SdkApiSettings.ApplicationKey, FrequencyPerDay = 4, RedirectUrl = callBackUrl, PsuIp = "127.0.0.1", SingleAccount = "BE91732047678076" }; BankingResult <string> bankingResult = await bankConnector.RequestAccountsAccessAsync(accountsAccessRequest); if (bankingResult.GetStatus() == ResultStatus.REDIRECT) { // We get the flow context. var flowContext = bankingResult.GetFlowContext(); string redirectUrlOnTheBank = bankingResult.GetData(); var psi = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"); psi.Arguments = redirectUrlOnTheBank; Process.Start(psi); Console.WriteLine("QueryString received?"); string queryString = Console.ReadLine(); BankingResult <IUserContext> result = await bankConnector.RequestAccountsAccessFinalizeAsync(flowContext, queryString); if (result.GetStatus() == ResultStatus.DONE) { Console.WriteLine("Ok. Cool."); BankingResult <List <Account> > accounts = await bankConnector.GetAccountsAsync(); foreach (Account account in accounts.GetData()) { Console.WriteLine("Account " + account.Iban); BankingResult <List <Balance> > resultBalances = await bankConnector.GetBalancesAsync(account.Iban); if (resultBalances.GetStatus() == ResultStatus.DONE) { List <Balance> accountBalances = resultBalances.GetData(); foreach (Balance balance in accountBalances) { Console.WriteLine(" Balance : " + balance.BalanceAmount + " " + balance.ReferenceDate?.ToString("dd MMM yyyy")); } } } } } Console.ReadLine(); return; }
static async Task Main(string[] args) { var services = new ServiceCollection(); services.AddBankingSdk(); string userContext = ""; string sourceIban = "LU147856985236589658"; /* * For payment */ string counterpartIban = "LU147856985236589659"; string counterpartName = "test"; string remittance = "Test BankingSDK payment to be refund"; double paymentAmount = 1.37; /* * the URL where the Bank will redirect. * Majority of banks requires it to be among the callback URLs defined during the sandbox or * production onboarding */ string callBackUrl = "https://www.bankingsdk.com/"; // Setting general settings of BankingSDk BankSettings generalBankSettings = new BankSettings(); // Official TPP ID given by central bank authorities generalBankSettings.NcaId = "VALID_NCA_ID"; // identification certificate aka QWAC // generalBankSettings.TlsCertificate = new X509Certificate2("ING-eidas_tls.pfx", "YOUR_PASSWORD"); // signing certificate aka QSEAL // generalBankSettings.SigningCertificate = new X509Certificate2("ING-eidas_signing.pfx", "YOUR_PASSWORD"); // URL of the public PEM file (rarely (never?) used in sandbox) generalBankSettings.PemFileUrl = "https://my.domain.tldn/qwac-public.pem"; /* * Data to identify your company and application in BankingSDK developer platform developer.BankingSDK.com */ SdkApiSettings.CompanyKey = "f954a771-509b-43c9-a064-0a3f9c9bb9d3"; SdkApiSettings.ApplicationKey = "4d972ae0-13cf-44ad-a20a-9ff44b884ce7"; SdkApiSettings.Secret = "MMH74H6OCI5CHPX1OS56PI6HSEGAVZ9PU8V8KTXL87ADBB23VJX1OFDDPAOZA53MIPRI4ZQ54T8SI2FRLMPMCIBP5RSKE7LCEX5WTU952164HV5W46NYQQKAOCMNHF07I5NU7T71NTTKLHHJW5QHUWWXN4HQHWYWB9VLHKZK9WL669ZH5D0LZSMVI0HCLQT157JLV5CLGFI7L00OFAVE5N7SW9CRDW9SCUA9ZNV9APEUJPKS936K5P5SA1YV3VIT"; /* * You TPP legal name */ SdkApiSettings.TppLegalName = "TTP_NAME"; /* * Want to work in sandbox mode, so the SDK will take bank's sandbox API URLs */ SdkApiSettings.IsSandbox = true; /* * Want to debug the body sent and received into developer.BankingSDK.com logging * Take care of privacy of the data contained in thos bodies !!! * Should only be used in production tests */ SdkApiSettings.IsDebug = true; /* * BNP */ /* * BNP App client Id and secret received when creating the sandbox app or when onboarding in production * Some bank only needs the client id, some don't use it and only need the identity inside the qwac cert */ generalBankSettings.AppClientId = "DefaultApplication_SANDBOX_c26a5f47-e6c4-41c5-8a8c-cb4ff7d4e006"; generalBankSettings.AppClientSecret = "0f64ed93-f9e4-4c4e-89e2-7dc8fc966ea3"; /* * Direct instantiation of the connector without using the BankingFactory. Mandatory when using connector * that are still in development which are not accessible through the factory */ var bankConnector = new LuBilConnector(generalBankSettings); /* * If you don't want to do the SCA into the bank each time you run the App, * grab the user context from the console debug output and past it here. * You should do it to test the token refreshing in the SDK Connector. * The user context may change when getting balance or transaction so pay attention to console output * This userContext should be saved for later reuse in a normal app */ userContext = "{\"UserId\":\"1d623d7c-d419-411e-9fa4-07a9979ac499\",\"Tokens\":[{\"TokenType\":\"Bearer\",\"AccessToken\":\"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJvSjNmUkF2Sk91TVZFTlZpRThobmFCM0pWRW5kSVo4el81RXd2dk5MVEdBIn0.eyJqdGkiOiJlYTk5OTZmNC04MWZiLTRlNzMtYTM4NS0zNWFhZjQyN2Q2ZTYiLCJleHAiOjE2MDc5NDYwOTYsIm5iZiI6MCwiaWF0IjoxNjA3OTQ1Nzk2LCJpc3MiOiJodHRwczovL2FwaS1sb2dpbi5iaWwuY29tL2F1dGgvcmVhbG1zL1RQUCIsImF1ZCI6ImJyb2tlciIsInN1YiI6IjU4NDQ0OWM2LTQ4MTUtNGQ3ZC04MzJiLWZlYzRiNWZlMTE4YiIsInR5cCI6IkJlYXJlciIsImF6cCI6IkRlZmF1bHRBcHBsaWNhdGlvbl9TQU5EQk9YX2MyNmE1ZjQ3LWU2YzQtNDFjNS04YThjLWNiNGZmN2Q0ZTAwNiIsIm5vbmNlIjoiOWIzNjNkMzgtNzUwMS00M2NhLTk5YjQtZDA4MWY2MTQ3MGQ3IiwiYXV0aF90aW1lIjoxNjA3OTQ0ODczLCJzZXNzaW9uX3N0YXRlIjoiMzQxNTYxZjItNmJjNi00NmZlLTg1ZDYtNmQwODVjOTYzMjgwIiwiYWNyIjoiMSIsInJlc291cmNlX2Fj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RNSOtGNXm7vAnkyMIO5eQ5tkfEEXI5Q\",\"Id\":\"7gg1f9d4d11255bb85x270377c2927b9\",\"Iban\":\"LU1600501964925789\",\"Currency\":\"EUR\",\"Description\":\"LU1600501964925789\"}]}"; //await bankConnector.RegisterUserAsync("1"); // What to test ? bool testConsent = false; bool testBalancesAndTransactions = false; bool testPayment = true; try { /* * GET CONSENT */ if (testConsent && (userContext == "")) { string userId = Guid.NewGuid().ToString(); userContext = (await bankConnector.RegisterUserAsync(userId)).GetData().ToJson(); bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged AccountsAccessRequest accountsAccessRequest = new AccountsAccessRequest { FlowId = Guid.NewGuid().ToString(), // Id you manage to link the request to the finalize FrequencyPerDay = 4, RedirectUrl = callBackUrl, PsuIp = "127.0.0.1", SingleAccount = sourceIban, // see BankingSDK doc BalanceAccounts = new List <string>() { sourceIban }, // see BankingSDK doc TransactionAccounts = new List <string>() { sourceIban } // see BankingSDK doc }; BankingResult <string> bankingResult = await bankConnector.RequestAccountsAccessAsync(accountsAccessRequest); if (bankingResult.GetStatus() == ResultStatus.REDIRECT) { /* * We get the flow context. It should be saved and * restored later when the bank call back your app * contains necessary data to finalize the consent */ var flowContext = bankingResult.GetFlowContext(); string redirectUrlOnTheBank = bankingResult.GetData(); Console.WriteLine("Got redirected to the bank : " + redirectUrlOnTheBank); Console.Write("Open URL ? [Y/n] :"); string openUrl = Console.ReadLine(); if (openUrl.ToUpper() != "N") { OpenUrl(redirectUrlOnTheBank); } Console.Write("Received queryString: "); string queryString = Console.ReadLine(); /* * The flowContext you should have restored in a web app, not needed in a console app :) */ BankingResult <IUserContext> result = await bankConnector.RequestAccountsAccessFinalizeAsync(flowContext, queryString); if (result.GetStatus() == ResultStatus.DONE) { Console.WriteLine("Cool, succesfuly got consent."); Console.WriteLine("************ User context to be saved :"); Console.WriteLine(bankConnector.UserContext.Replace("\"", "\\\"")); userContext = bankConnector.UserContext; bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged } } } /* * GET BALANCES AND TRANSACTIONS */ if (testBalancesAndTransactions && (userContext != "")) { bankConnector.UserContext = userContext; BankingResult <List <Account> > accounts = await bankConnector.GetAccountsAsync(); foreach (Account account in accounts.GetData()) { Console.WriteLine("Account " + account.Iban); BankingResult <List <Balance> > resultBalances = await bankConnector.GetBalancesAsync(account.Id); if (bankConnector.UserContextChanged) { Console.WriteLine("************ User context has changed :"); Console.WriteLine(bankConnector.UserContext.Replace("\"", "\\\"")); userContext = bankConnector.UserContext; bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged } if (resultBalances.GetStatus() == ResultStatus.DONE) { List <Balance> accountBalances = resultBalances.GetData(); foreach (Balance balance in accountBalances) { Console.WriteLine(" Balance : " + balance.BalanceAmount.Amount + balance.BalanceAmount.Currency + " (" + balance.BalanceType + ") " + balance.ReferenceDate?.ToString("dd MMM yyyy")); } } var requestedAt = DateTime.Now; TransactionsPaginatedDto paginatedDto = new TransactionsPaginatedDto(); paginatedDto.Page = 0; paginatedDto.Size = 1000; paginatedDto.Total = 0; paginatedDto.Transactions = new List <TransactionDto>(); IPagerContext pagerContext = bankConnector.CreatePageContext(100); while (!pagerContext.IsLastPage()) { BankingResult <List <Transaction> > resultTransactions = await bankConnector.GetTransactionsAsync(account.Id, pagerContext); if (bankConnector.UserContextChanged) { Console.WriteLine("************ User context has changed :"); Console.WriteLine(bankConnector.UserContext.Replace("\"", "\\\"")); userContext = bankConnector.UserContext; bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged } pagerContext = resultTransactions.GetPagerContext(); if (resultTransactions.GetStatus() == ResultStatus.DONE) { List <Transaction> accountTransactions = resultTransactions.GetData(); foreach (Transaction transaction in accountTransactions) { TransactionDto dto = new TransactionDto(); dto.Amount = transaction.Amount; dto.Currency = transaction.Currency; dto.Description = transaction.Description; dto.CounterpartReference = transaction.CounterpartReference; dto.CounterpartName = transaction.CounterpartName; dto.ExecutionDate = transaction.ExecutionDate; dto.ValueDate = transaction.ValueDate; dto.RequestedAt = transaction.ValueDate; dto.Id = Guid.NewGuid(); paginatedDto.Transactions.Add(dto); paginatedDto.Total += accountTransactions.Count; Console.WriteLine(" Transaction : " + transaction.Amount + transaction.Currency + " From " + transaction.CounterpartName + "/" + transaction.CounterpartReference + " (" + transaction.Description?.Replace("\n", "\\n") + ") Exec: " + transaction.ExecutionDate?.ToString("dd MMM yyyy") + ", Value: " + transaction.ValueDate?.ToString("dd MMM yyyy")); } } // break; pagerContext.NextPage(); } string json = JsonConvert.SerializeObject(paginatedDto, Formatting.Indented); // Console.WriteLine(json); } } /* * DO PAYMENT */ if (testPayment) { Console.WriteLine("+++++ Initiating payment"); if (string.IsNullOrEmpty(userContext)) { await bankConnector.RegisterUserAsync(Guid.NewGuid().ToString()); } else { bankConnector.UserContext = userContext; } var paymentInitResult = await bankConnector.CreatePaymentInitiationRequestAsync( new PaymentInitiationRequest { FlowId = Guid.NewGuid().ToString(), Amount = new decimal(paymentAmount), Currency = "EUR", Recipient = new RecipientInfo { Iban = counterpartIban, Name = counterpartName }, Debtor = new DebtorInfo { Iban = sourceIban, Name = "test", Currency = "EUR" }, RequestedExecutionDate = DateTime.Now, PsuIp = "80.80.0.0", RedirectUrl = callBackUrl, EndToEndId = Guid.NewGuid().ToString().Replace("-", ""), RemittanceInformationUnstructured = remittance }); if (bankConnector.UserContextChanged) { Console.WriteLine("***** User context has changed :"); Console.WriteLine(bankConnector.UserContext.Replace("\"", "\\\"")); userContext = bankConnector.UserContext; bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged } if (paymentInitResult.GetStatus() == ResultStatus.REDIRECT) { Console.WriteLine($"----- Payment init done @{DateTime.UtcNow}, getting consent"); // We get the flow context. var flowContext = paymentInitResult.GetFlowContext(); string redirectUrlOnTheBank = paymentInitResult.GetData(); Console.WriteLine("Got redirected to the bank : " + redirectUrlOnTheBank); Console.Write("Open URL ? [Y/n] :"); string openUrl = Console.ReadLine(); if (openUrl.ToUpper() != "N") { OpenUrl(redirectUrlOnTheBank); } Console.Write("Received queryString: "); string queryString = Console.ReadLine(); Console.WriteLine("----- Got consent, finalizing"); BankingResult <PaymentStatus> paymentFinalizeResult = await bankConnector.CreatePaymentInitiationRequestFinalizeAsync(flowContext, queryString); if (bankConnector.UserContextChanged) { Console.WriteLine("***** User context has changed :"); Console.WriteLine(bankConnector.UserContext.Replace("\"", "\\\"")); userContext = bankConnector.UserContext; bankConnector.UserContext = userContext; // Only way to reset the bankConnector.UserContextChanged } if (paymentFinalizeResult.GetStatus() == ResultStatus.DONE) { Console.WriteLine("----- Payment finalized. current status :"); string json = JsonConvert.SerializeObject(paymentFinalizeResult.GetData(), Formatting.Indented); Console.WriteLine(json); Console.WriteLine(">>>>> Payment finished"); } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } // Console.ReadLine(); }