Manage Finances with 4D E-Banking SDK (aka IPWorks OFX)


Requirements: 4D E-Banking SDK

Introduction

OFX (Open Financial eXchange) is an XML standard for exchanging financial data between financial institutions and client applications. The standard was formed in the late 1990’s as a joint venture between several entities, including Microsoft and Intuit, as a way for their applications (Money and Quicken) to access financial accounts. The protocol allows clients to manage many aspects of financial accounts including the retrieval of transaction information, bill payment, bill presentment, etc.

This article will use OFX and email to demonstrate how you can receive instant notification of credit card and bank transactions. By receiving these notifications you can quickly review transactions and rapidly respond to any fraudulent charges which might occur.

How Does it Work?

For this article we’ll be using the .Net Edition of 4D E-Banking SDK, though the code and components are available for .Net and Java. As all 4D Payments components keep the same interfaces across development technologies, the code in this article could very easily be recreated in Java or JSP for example.

4D E-Banking SDK can be used to connect to and retrieve live financial data from banks, credit card, and investment companies. The 4D E-Banking SDK contains several components which use the OFX protocol and SSL technology to communicate with these financial institutions.

The E-Banking SDK components BankStatement (for banking accounts), CCStatement (for credit card accounts), and InvStatement (for investment services accounts) components all have the ability to connect to and download a statement from a financial institution. This is done through the GetStatement method of these components. They also have the capability of loading statements from an OFX file saved to disk, such as the kind most banks allow you to download from their “Online Banking” services website, through the ReadOFXDataFile method of the components.

Configuring the E-Banking SDK Components

In this example we’ll connect to American Express and download the transaction information for a specific account. Connecting and downloading transaction information from credit card companies is done with the CCStatement component.

Ccstatement card = new Ccstatement(); card.OFXUser = "[User Name]"; card.OFXPassword = "[Password]"; card.FIUrl = "https://www99.americanexpress.com/myca/ofxdl/us/download?" + "request_type=nl_desktopdownload" card.FIId = "3101"; card.FIOrganization = "AMEX"; card.OFXAppId = "Money"; card.OFXAppVersion = "1400"; card.CardNumber = "[CardNumber]"; DateTime fromdate = DateTime.Now.Subtract(new TimeSpan(24, 0, 0)); card.StartDate = fromdate.ToString(); //last 24 hrs card.EndDate = "";

The OFX User and Password above represent the user name and password used to login to American Express online for account management. Most credit card companies use the same user name and password for OFX retrieval as they do for online access. Some companies however require a special registration which provides a different user name and password for OFX integration. Follow the instructions for connecting with Quicken or Microsoft Money to find out about any special requirements for your financial institutions.

The Financial Institution properties (FI properties above) are all required and institution specific. These are required in order to connect to and download OFX data. If you have trouble finding the FI data for your bank or credit card account, contact our support team at support@4dpayments.com for help finding the connection information.

In addition, we’ve set the OFXAppId and OFXAppVersion properties. You can just replicate the values that Microsoft Money sends, as we’ve done in this example. This is not a required step, however some financial institutions will only accept requests from trusted clients.

Finally, set the CardNumber, StartDate, and EndDate to define the transaction set. CardNumber is used to tell American Express which account transactions to provide in the event that you have multiple American Express cards. If we leave StartDate and EndDate empty, American Express will send all of the transactions still available on the server. Commonly one might download a statement for the entire month. In this example, for simplicity, we’ll only retrieve transactions for the last 24 hours.

Downloading Transactions and Building the Email

After setting the card properties, calling the GetStatement method causes the CCStatement component to connect to the server specified by the FIUrl and request the specified transaction set. After completing the statement request, one is presented with an array of transactions that can be used to build the email of transactions.

card.GetStatement(); //prepare email headers: htmlmailers1.Subject = "Statement for " + card.StartDate + " - " + card.EndDate; htmlmailers1.From = "[sender email]"; htmlmailers1.SendTo = "[recipient email]"; htmlmailers1.MailServer = "[your mail server]"; //prepare email body: string msgbody = ""; msgbody += "As of " + card.LedgerBalanceDate + ", your balance is <strong>" + card.LedgerBalance + "</strong><p />"; msgbody += "<table cellspacing=\"10\">"; for (int i = card.TxCount; i >= 1; i--) { if (Convert.ToDouble(card.TxAmount[i]) > 0) msgbody += "<tr bgcolor=\"LightYellow\">"; else if (i % 2 == 0) msgbody += "<tr bgcolor=\"#e7e7e7\">"; else msgbody += "<tr>"; msgbody += "<td>" + card.TxDatePosted[i] + "</td><td>" + card.TxPayeeName[i] + "</td><td>" + card.TxAmount[i] + "</td></tr>"; } msgbody += "</table>"; htmlmailers1.MessageHTML = msgbody; //send the email htmlmailers1.Send();

While iterating over the credit card transactions, we can simultaneously build an email using the IPWorks HTMLMailerS component. All we are doing at this point is formatting the transaction information returned by the CCStatement component and adding each transaction to the html email as a table row.

Using the formatting above, the email would look like this:

As of 3/4/2022 6:00:00 PM, your balance is 624.24

3/4/2022 6:00:00 PM My Power Company -79.26
3/4/2022 6:00:00 PM Pizza Pizza -11.69
3/2/2022 6:00:00 PM My Grocery -30.58
3/2/2022 6:00:00 PM Auto Motor Company -440.00
3/1/2022 6:00:00 PM Cell Phone, Inc. -29.77
3/1/2022 6:00:00 PM Electronics Anonymous -32.94

Security

The communication between the OFX components and the server itself is automatically protected with SSL security. Before sending this data in an email, we would recommend that you also make sure that the connection between the email component and your mail server is also secure. We’ve done that in this example by using an SSL HTMLMailerS component to connect to an SSL-capable mail server.

More Functionality

Currently this article only demonstrates how to connect to a single credit card corporation to download transaction information. However, the interface for connecting with bank account information (the BankStatement component) is virtually identical to the CCStatement component. Also, the InvStatement component can be used to acquire a statement from your investment brokerage. Using a combination of the components in the E-Banking SDK it is possible to provide an overview of all current transactions for all of your accounts.

There are all kinds of applications for the OFX components. You can monitor your credit card transactions as shown in this article, watch your investment portfolio value, keep track of monthly credit card and bank statements, compare your statements to your budget, create balance projections, categorize transactions by payee, etc.

There are also all kinds of notification methods you could use to stay on top of your financial accounts. If you don’t want to send email, you could also use instant messaging (like XMPP), pager messages (SNPP), mobile phone text messages (SMS), or even use an RSS feed. If you use RSS feeds you can take advantage of RSS feed reader abilities to only show new RSS items so that every time you check the feed you’ll only see transactions since the last time you checked.

As was mentioned earlier in this article, providing some level of security is also an important feature that should be incorporated in this application. SSL security and some level of user and password authentication should be required when accessing sensitive transaction information.


We appreciate your feedback. If you have any questions, comments, or suggestions about this entry please contact our support team at support@4dpayments.com.