Programming the Ingenico 6770 in C#

One of the more troublesome projects I’ve been working in is adding signature capture + MSR to a desktop application. One of the hardware pieces we added support for is the Ingenico 6770. The good news is that with the economic downturn you can get them for a steal on eBay. But your customers may be loathe to spend what these cost new…

Regardless, here are my initial observations:

  • While you may be able to get this working in straight .NET code with the Microsoft PointOfService libraries – it isn’t worth it. Your customers will need to install the driver software from Ingenico to get the device working at all, and that software installs some ActiveX objects that expose far more reliable and powerful API methods.
  • Yes, you heard me correctly – ActiveX controls. Ingenico seriously needs to work on improving their API.
  • Ingenico also does not supply any of their SDKs directly on their web site. You will need to contact the company via phone or email and ask for a link to the SDK’s. Once you do so be sure to get both the SDK for the product you are working on, along with the “Signature SDK.” They do not come in one package or location.
  • Once you get the SDKs and add them to your project most parts are fairly simple. The only major problem I had was with extracting the signature from the library into a string I could save to the database, so it could be read back and displayed to the user later. It turns out that while the regular SDK documents never mentioned it, the signature SDK did mention that you must set BinaryConversion to OPOS_BC_NIBBLE in order to get this working.
  • SDK did not say what the value for OPOS_BC_NIBBLE is…. I’ll tell you it’s 1.

Pricing Windows Azure, Amazon S3 and the Google App Engine

Microsoft has finally announced the pricing model for Windows Azure (Confirming Commercial Availability and Announcing Business Model). Azure has generated a lot of buzz among Windows or .NET developers but one of the major unknown factors was pricing. While it’s easy to develop a test case against the Azure “beta” now, you’d be mad to base any major business changes without knowing the price yet. While there are several other unknowns to grapple with (SLA, availability, reliability…) at least this question has been answered. In short:

Upon commercial availability we will offer Windows Azure through a consumption-based pricing model, allowing partners and customers to pay only for the services that they consume.

Windows Azure:

  • Compute @ $0.12 / hour
  • Storage @ $0.15 / GB stored
  • Storage Transactions @ $0.01 / 10K
SQL Azure:

  • Web Edition – Up to 1 GB relational database @ $9.99
  • Business Edition – Up to 10 GB relational database @ $99.99
.NET Services:

  • Messages @ $0.15/100K message operations , including Service Bus messages and Access Control tokens

Bandwidth across all three services will be charged at $0.10 in / $0.15 out / GB

Microsoft’s major competitors in the “Cloud” marketplace are Amazon S3 and the Google App Engine.

Microsoft’s major advantage over The Google App Engine is the relative ease by which you can integrate a traditional desktop integration with an app or database hosted online. The Google App Engine is an online-only service, and you are limited only to programming in Java and Python. The pricing for the Google App Engine includes a free quota, but beyond that you must pay:

Resource Unit Unit cost
Outgoing Bandwidth gigabytes $0.12
Incoming Bandwidth gigabytes $0.10
CPU Time CPU hours $0.10
Stored Data gigabytes per month $0.15
Recipients Emailed recipients $0.0001

Amazon S3 is the major established player in this market. Amazon started offering S3 about three years ago, and many very successful businesses (Twitter, for one) use S3 to host files, images, or increase performance. For simple file storage, they cannot be beat. However, it is not an application or relational database service. It is a very cheap and efficient means to store files. Their pricing model is as follows:

* $0.150 per GB – first 50 TB / month of storage used
* $0.140 per GB – next 50 TB / month of storage used
* $0.130 per GB – next 400 TB /month of storage used
* $0.120 per GB – storage used / month over 500 TB

Data Transfer
* $0.100 per GB – all data transfer in

* $0.170 per GB – first 10 TB / month data transfer out
* $0.130 per GB – next 40 TB / month data transfer out
* $0.110 per GB – next 100 TB / month data transfer out
* $0.100 per GB – data transfer out / month over 150 TB

* $0.01 per 1,000 PUT, COPY, POST, or LIST requests
* $0.01 per 10,000 GET and all other requests*

The choice of service largely depends on the business needs of your application (pricing is very similar), but it’s good to see the competition from three major players in this space.

Connecting to the Google Calendar API from C# or VB.NET

The Google calendar API is at its root very powerful, but you have not worked with XML/HTTP, cookies or authentication in the past learning the raw API can be  daunting. Fortunately Google provides a free .NET library, so you can interact with a user’s Google Calendar using intuitive .NET classes and methods.

To get started, download the .NET client API from here:

Add references to the Google libraries in your project, and use or import these in your code

using Google.GData.Client;
using Google.GData.Calendar;
using Google.GData.Extensions;

The library provides a “Service” class to handle connecting to and authenticating with Google:

Service service = new Service("cl", "companyName-appName-1");
service.setUserCredentials("", "userpassword");

You then execute a query on the service. The query will return a list of AtomEntry objects, which are handy wrappers for standard RSS Atom entries. For example, this returns a list of all items in the user’s calendar:

FeedQuery query = new FeedQuery();
query.Uri = new
AtomFeed calFeed = service.Query(query);
foreach (AtomEntry entry in calFeed.Entries)

There are similar methods for adding, updating, or deleting calendar items. For example:

AtomPerson author = new AtomPerson(AtomPersonType.Author);
author.Email = "";
entry.Title.Text = "Lunch at Bully's";
entry.Content.Content = "Eat lunch with Fred";
When eventTimes = new When();
eventTimes.StartTime = DateTime.Parse("7/13/2009 12:00:00 PM");
eventTimes.EndTime = DateTime.Parse("7/13/2009 1:00:00 PM");
Uri postUri = new Uri("");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);

Google provides extensive documentation and sample code, in a dazzling variety of languages. Even Objective-C for you Mac developers.

As with any scenario where the data can be updated from multiple locations, your application will have to implement synchonization logic. The items you upload one day could be deleted from the web or from the user’s iPhone before your next sync. But fortunately the sometimes daunting task of communicating with the remote service is trivial in this case.

A Handful of New Web Application Tools

  1. People like graphs. A graph or a chart can show exactly the same data as a table, but in a far more efficient and human-friendly manner. HTML is great at displaying tabled but not at charts, but now we have a very simple jQuery plugin that will generate charts and graphs directly from HTML tables. Just install the jQuery visualize plugin and call a table’s .visialize() method, and viola – instant charts. Yes, it’s really that easy. Put it on one of your sites today, tell your boss it took hours, and take a long lunch instead.
  2. Need to do a screen capture of a web page, but away from your regular computer? With Aviary’s Talon, you can do a screen capture of any web page directly from a web browser. I can see using this is you need to do screen captures from a portable device like an iPhone or netbook PC, or if you want to do a screen capture for a different screen resolution.
  3. Ruby on Rails developers should really check out LESS – an “extension” to CSS that adds what CSS should have such as variables.
  4. Anemone is a free, multi-threaded Ruby web spider framework from Chris Kite, which greatly simplifies your web spiders. For example:
require 'anemone'

Anemone.crawl("") do |anemone|
  anemone.on_every_page do |page|
    puts page.url

Programming for the MagTek USB Credit Card Readers

If you are tasked with integrating credit card “swiping” into a .NET application – I strongly suggest starting with the Magnetic Swipe Readers (MSR) from MagTek. While your mileage may vary, this is the one product I have been able to integrate with my application easily, and without any additional libraries or cumbersome third party libraries. That is, provided you remember two things:

  1. Purchase a HID (Human Interface Compliant) version of the MSR – NOT a keyboard emulation product. And
  2. Download the excellent HIDLibrary from Mike Obrian, which provides all the code you’ll need for inetgrating the reader into your .NET application.

There are no third party libraries or software needed. Windows should recognize the reader as a HID device when it is plugged in, and the HIDLibrary code should be able to interface with your reader. There are even samples and classes specific to MagTek MSRs on the library download page.

You will need to do a little research into the data format for credit card track data – data comes in a long binary array that must be converted toa  string, then parsed to separate the tracks and account number data. Here is a document describing the data format for credit card tracks to get you started.


HIDLibrary has been moved to GitHub, and updated since this post.

Payment Processing: An Introduction

For the past several weeks, I’ve been tasked with integrating payment processing into a desktop program. In the past I have added payment processing to several web sites, but integrating with desktop applications introduces many new complications. Not the lest of which is hardware, hardware, hardware. The good news is that you can buy just about any payment processing hardware you’ll need on eBay for about 5-25% of the retail cost. This makes it easy and very cost effective to add support for a multitude of devices in your application, if clients require that. The bad news is that many of these devices require a unique API, and come with scanty or no documentation. But once you get everything working together it’s a beautiful thing. Payment processing is the lifeblood of any business, and by making it more efficient, cost effective, and less error prone you are doing your clients a great service.

This will probably be the first in a series of posts on the subject, so here are my initial observations.

Any Payment Processing solution requires at least two modules:

  1. Data Input: This could be as simply having users enter credit card or EFT (banking) information into a form. However, if at all possible you should support a hardware-based solution such as a Magnetic Swipe Reader (MSR) or Magnetic Ink Check Reader (MICR). For credit card transactions, most payment gateways provide significantly lower fees for swiped credit card transactions due to lower error and fraud rates. While the fees for EFT transactions may not be lower for your payment gateway, the ease of use and lower error rates make MICR readers a great addition to your application.
  2. Payment Gateway: Once you have the users credit card or bank information, your application must communicate with a payment processor or gateway that handles all the details about validating the card, funds, and transferring funds from the customer’s account to the merchant account. In my experience this is the easy part – most payment processors supply a rich and well documented API compleet with sample code, controls, and libraries. If they do not, choose a different one!

6 Amazing Techniques to Staying Happy During a Stressful Project

Another good post from Zen Habits. Here’s an excerpt:

2. Break The Project Down Into Tiny Chunks
The length of my list on any given day would scare even Warren Buffett. I expect too much and never feel satisfied.

Instead of getting a whole bunch of stuff done, my brain often shuts down in response to my overwhelming list. I need to figure out a way to reduce those negative thoughts by listening to them and reasoning with them. I have tried being a big bully and forcing myself to do work, but this technique always lacked results.

I’ve created a routine that allows me to handle my work load. When I realize that I have overextended my “to do” wish list, I stand up, breathe deep, and let out the air as I take a moment to refill my glass with water.

I then break down my first big task into twenty minute chunks. When the project seems more manageable, I pick an easier 20 minute chunk and accomplish it. By doing this I boost my confidence and get my emotions back into a positive state.

jQuery libraries, blog comments, and funnies

Here are a few quick items found in today’s feeds:

jqDock: a jQuery “Fish Eye” dock. For those who love the Mac interface or develop for those who do.

jQuery-based advanced docking: Interesting implementation. If you have an incredibly complex web interface, and need it to be highly customizable for users, this is worth a look.

Is Commenting on Blogs a Smart Traffic Strategy: Common sense here. Don’t spam, develop relationships.

25 Best Programmer WebComics