uc_card

A Ruby library that fetches your unpaid credit card transaction history (usage statements) from the UC Card (www.uccard.co.jp) member site. It logs in to the member site with Mechanize, opens the statement page, parses the HTML with Nokogiri, and returns the results as Ruby objects.

Published as a gem, with a command-line tool of the same name bundled in.

gem install uc_card
uc_card   # 未払いの取引を一覧表示(オプションは一切ない)

Sample output from the README (merchant names are masked).

2012/01/28: ****** 500 1回払い 1回
2012/01/26: ****** 5940 1回払い 1回
2012/01/22: ****** 3357 1回払い 1回
Total: 11722

Used as a library, it looks like this. Instead of hard-coding the ID and password, it reads them from pit, a credential-management library.

require 'uc_card'
UCCard.start_with_pit("uccard.co.jp") do |card|
  puts card
end

Internals

UCCard.start takes care of the whole lifecycle from login through statement retrieval to logout, and the block receives a fully parsed instance.

Sequence diagram of the uc_card processing flow

The README includes a note that if you get SSL certificate errors, you should locate the certificate path with ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE" and install an appropriate certificate.