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 RSS feed of recent transactions.
Code Listing 3
card.GetStatement();
for (int i = 1; i <= card.TxCount; i++)
{
string title = string.Format("{0} : {1} - {2} - {3}",
card.FIOrganization,
formatCurrency(card.TxAmount[i]),
card.TxPayeeName[i],
formatDate(card.TxDatePosted[i]) );
string description = string.Format(
"<table border=0>" +
"<tr><td>Date:<td>{0}<tr><td>Type:<td>{1}" +
"<tr><td>Amount:<td>{2}<tr><td>Payee:<td>{3}" +
"</table>\r\n",
formatDate(card.TxDatePosted[i]),
card.TxTypeDescription[i],
formatCurrency(card.TxAmount[i]),
card.TxPayeeName[i] );
rss.AddItem (title, description, "");
rss.ItemPubDate[1] = formatDate(card.TxDatePosted[i]);
rss.ItemGuid[1] = card.TxFITID[i];
}
While iterating over the credit card transaction, we can simultaneously build our RSS feed using the IP*Works! RSS component. All we are doing at this point is formatting the returned transaction information and adding each transaction as an RSS item. The date and currency formatting functions called above are used to normalize dates and currencies provided in the credit card transaction set.
One thing to note here is that the AddItem method of the RSS object adds RSS items to the beginning of the item list. Every iteration over the Credit Card transaction set inserts a new RSS item to our feed. After inserting the RSS item, set the ItemPubDate and the ItemGuid so that the transactions are listed correctly in our feed reader as they are returned from the credit card company.
Using the formatting above, RSS items will show though your feed reader with the following title and item body:
---------------------------------
AMEX : - $19.43 – OUTBACK STEAKHOUSE #0172 RICHMOND -
7/16/2005 8:00:00 PM
Date : 7/16/2005 8:00:00 PM
Type : Debit
Amount : - $19.43
Payee : OUTBACK STEAKHOUSE #0172 RICHMOND
---------------------------------