Updated version and added example code
This commit is contained in:
parent
e0ffec4127
commit
01dcd502c5
60
README.md
60
README.md
|
@ -25,7 +25,7 @@ Not uploaded to Maven Central yet, will do this the next few days!
|
||||||
Gradle:
|
Gradle:
|
||||||
```
|
```
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'net.dankito.banking:fints4java:0.1'
|
compile 'net.dankito.banking:fints4java:0.1.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -34,17 +34,69 @@ Maven:
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dankito.banking</groupId>
|
<groupId>net.dankito.banking</groupId>
|
||||||
<artifactId>fints4java</artifactId>
|
<artifactId>fints4java</artifactId>
|
||||||
<version>0.1</version>
|
<version>0.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Get your bank's FinTS server address and BIC from this file:
|
See e.g. [JavaShowcase](fints4javaLib/src/test/java/net/dankito/fints/java/JavaShowcase) or [FinTsClientTest](fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest).
|
||||||
|
|
||||||
```java
|
```java
|
||||||
FinTsClient client = new FinTsClient();
|
public static void main(String[] args) {
|
||||||
|
BankFinder bankFinder = new BankFinder();
|
||||||
|
|
||||||
|
// set your bank code (Bankleitzahl) here. Or create BankData manually. Required fields are:
|
||||||
|
// bankCode, bankCountryCode (Germany = 280), finTs3ServerAddress and for bank transfers bic
|
||||||
|
List<BankInfo> foundBanks = bankFinder.findBankByBankCode("10070000");
|
||||||
|
|
||||||
|
if (foundBanks.isEmpty() == false) {
|
||||||
|
BankData bank = new BankDataMapper().mapFromBankInfo(foundBanks.get(0));
|
||||||
|
// set your customer data (customerId = Kontonummer in most cases, pin = online banking pin)
|
||||||
|
CustomerData customer = new CustomerData("<customer_id>", "<pin>");
|
||||||
|
customer.setSelectedTanProcedure(new TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTan));
|
||||||
|
|
||||||
|
FinTsClient finTsClient = new FinTsClient(new Java8Base64Service());
|
||||||
|
|
||||||
|
// some banks support retrieving account transactions of last 90 days without TAN
|
||||||
|
long ninetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L;
|
||||||
|
Date ninetyDaysAgo = new Date(new Date().getTime() - ninetyDaysAgoMilliseconds);
|
||||||
|
|
||||||
|
GetTransactionsResponse response = finTsClient.getTransactions(
|
||||||
|
new GetTransactionsParameter(true, ninetyDaysAgo), bank, customer);
|
||||||
|
|
||||||
|
showResponse(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void showResponse(GetTransactionsResponse response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
System.out.println("Balance (Saldo) = " + response.getBalance());
|
||||||
|
|
||||||
|
System.out.println("Account transactions (Umsätze):");
|
||||||
|
for (AccountTransaction transaction : response.getBookedTransactions()) {
|
||||||
|
System.out.println(transaction.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (response.isStrongAuthenticationRequired()) {
|
||||||
|
System.out.println("Sorry, your bank doesn't support retrieving account " +
|
||||||
|
"transactions of last 90 days without TAN");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("An error occurred:");
|
||||||
|
if (response.getException() != null) { // something severe occurred
|
||||||
|
System.out.println(response.getException().getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// error messages retrieved from bank (e.g. PIN is wrong, message contains errors, ...)
|
||||||
|
for (String retrievedErrorMessage : response.getErrorsToShowToUser()) {
|
||||||
|
System.out.println(retrievedErrorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue