Giter VIP home page Giter VIP logo

ofx4j's Introduction

Welcome to OFX4J!

This project provides an implementaion of OFX for Java.

Build Status

Coordinates

Maven

<dependency>
  <groupId>com.webcohesion.ofx4j</groupId>
  <artifactId>ofx4j</artifactId>
  <version>1.13</version>
</dependency>

OFX Client

Lookup Your Financial Institution

You have to first find the financial institution you want to interface with. Use an implementation of com.webcohesion.ofx4j.client.FinancialInstitutionDataStore to list the available financial institution data. Alternatively, use com.webcohesion.ofx4j.client.impl.BaseFinancialInstitutionData to construct your own data if your FI data isn't available.

The two default implementations of FinancialInstitutionDataStore are com.webcohesion.ofx4j.client.impl.LocalResourceFIDataStore and com.webcohesion.ofx4j.client.impl.OFXHomeFIDataStore. The former looks up the data store list from a local resource (default is the list at /META-INF/ofx4j/institutions.xml on the classpath; a default one is packaged with the jar). The latter screen-scrapes this page at OFX Home, so it's subject to break depending on how often the format of that page changes.

Once you have a reference to the FinancialInstitutionData you want, you can now use it to interface with your FI.

Interfacing With Your Financial Institution

FinancialInstitutionData data = ...;
FinancialInstitutionService service
  = new FinancialInstitutionServiceImpl();
FinancialInstitution fi = service.getFinancialInstitution(data);

// read the fi profile (note: not all institutions
// support this, and you normally don't need it.)
FinancialInstitutionProfile profile = fi.readProfile();

//get a reference to a specific bank account at your FI
BankAccountDetails bankAccountDetails
  = new BankAccountDetails();

//routing number to the bank.
bankAccountDetails.setRoutingNumber("11111111");
//bank account number.
bankAccountDetails.setAccountNumber("1234-5678");
//it's a checking account
bankAccountDetails.setAccountType(AccountType.CHECKING);

BankAccount bankAccount
  = fi.loadBankAccount(bankAccountDetails, "username", "password");

//read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
  = bankAccount.readStatement(startDate, endDate);

// get a reference to a specific credit card
// account at your FI
CreditCardAccountDetails ccDetails
  = new CreditCardAccountDetails();
ccDetails.setAccountNumber("1234-567890-1111");
CreditCardAccount ccAccount
  = fi.loadCreditCardAccount(ccDetails, "username", "password");

// read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
  = ccAccount.readStatement(startDate, endDate);

OFX Server

You can use OFX4J to implement your own OFX server. To do so, you must implement the com.webcohesion.ofx4j.server.OFXServer interface. Once an adequate implementation of this interface is exists, you can use the com.webcohesion.ofx4j.server.OFXServlet in your J2EE application, passing the name of the OFXServer implementation in the "ofx-server-class" init parameter.

<web-app>

  ...

  <servlet>
    <servlet-name>OFXServlet</servlet-name>
    <servlet-class>com.webcohesion.ofx4j.server.OFXServlet</servlet-class>
    <init-param>
      <param-name>ofx-server-class</param-name>
      <param-value>fqn.of.the.OFXServerImpl</param-value>
    </init-param>
    <!-- uncomment to use OFX v2
    <init-param>
      <param-name>ofx-version</param-name>
      <param-value>2</param-value>
    </init-param>
    -->
  </servlet>

  ...

  <servlet-mapping>
    <servlet-name>OFXServlet</servlet-name>
    <url-pattern>/ofx</url-pattern>
  </servlet-mapping>

  ...

</web-app>

OFX I/O

Reading OFX data

OFX4J boasts a very fast, event-based OFX reading mechanism. If you've got a file or other stream resource, you can read it using an instance of com.webcohesion.ofx4j.io.OFXReader. We suggest the com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader, which uses utilities provided by the NanoXML project. This reader will detect the version of OFX being used (version 1 or 2) and parse it accordingly.

Or you want to unmarshal the OFX directly to a Java object, use the com.webcohesion.ofx4j.io.AggregateUnmarshaller.

Writing OFX data

You can also write OFX data using an instance of com.webcohesion.ofx4j.io.OFXWriter. com.webcohesion.ofx4j.io.v1.OFXV1Writer is used to write OFX version 1 and com.webcohesion.ofx4j.io.v2.OFXV2Writer is used to write OFX version 2. If you want to marshal from Java objects, use the com.webcohesion.ofx4j.io.AggregateMarshaller

Support

Try the issue tracker.

ofx4j's People

Contributors

stoicflame avatar axiopisty avatar ashgupta1489 avatar dhilst avatar ghe2014 avatar fleminra avatar

Watchers

Eduardo Bellani avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.