Shared item
1 shares
Billing on the Brain: Credit Card Storage
via Dynamite - The Err Free Weblog by PJ Hyett on February 06, 2008
FamSpam is a subscription-based service, so we had to come up with a solution for billing customers every month. One solution would be to mail them monthly invoices like a credit card statement. The other, not completely insane solution, is to just store their credit card information and use it when it comes time to bill them each month.
How does one store credit card info?
You have two options: store it yourself or pay someone to store it for you. For us, storing credit card information on our servers was out of the question. The technical and legal hurdles are enormous, and just like our stance on using someone to send our email, this is absolutely another service that’s worth paying for.
Where does one store credit card info?
The simplest solution is to find a merchant that also has some sort of secure ‘vault’ service. The concept is straightforward: you give them the customer’s credit card info, they give you back a vault id that you store, and then you use that vault id anytime you need to bill them.
Code on Dynamite?
ActiveMerchant has support built-in for dealing with vaults, so using them works something like the following:
Step 1: Bill using credit card (and storing card in vault)creditcard=ActiveMerchant::Billing::CreditCard.new(:type=>'visa',:number=>'4242424242424242',:month=>8,:year=>2009,)gateway.purchase(1000,creditcard,:store=>true)
Step 2: Bill using vault idgateway.purchase(1000,vaultid)
Not only does ActiveMerchant have a great API, it also includes wrappers for over two dozen gateways. Give it a good look before you roll your own code.
But, wait, there’s more!
Next up is how to handle subscriptions now that we know how to store credit cards, the suspense is killing me!
Shared by: