Record credit card failures in the DB

Finally got around to finishing this work that I had hanging in a local branch. Implements #364.