CheddarGetter for Python and Django

Jason Ford // Jan. 31, 2010

We believe in the philosophy of not reinventing the wheel if we don't have to. That's why we use Django as our development framework. And that's why we decided to use CheddarGetter - a web service that takes care of all of our recurring credit card billing. We wrote a wrapper for CheddarGetter in Python, called PyCheddar, and have released it as open source so others can take advantage of it as well.

Why we like CheddarGetter

CheddarGetter abstracts the entire process of managing credit cards, processing transactions on a recurring basis, and even more complex setups like free trials, setup fees, and overage charges. Writing that from scratch would take forever. We'd end up spending months writing code that doesn't do anything to help businesses harness social media - all it does it help us get their money.

By using CheddarGetter, we can let their team focus on writing, improving, and maintaining the code base for billing, while we work on the core features and functionality for FeedMagnet.

Making CheddarGetter Pythonic

While CheddarGetter is great and saved us a bunch of time, we did have to write some code on our end before we could start interacting with it in Python - but the good news is, since we're open sourcing PyCheddar - you won't have to.

I started the project by writing a simple wrapper for CheddarGetter in Python - just mapping API methods to Python methods and automating the process of authenticating and hitting the API. Luke came along behind me and completely re-wrote it to be object oriented and much more Pythonic.

The current version of PyCheddar wraps all of your interactions with the billing system into a few objects: Customer, Plan, Subscription, and Invoice. They work almost identical to Django models.

You can authenticate:

>>> from pycheddar import *
>>> CheddarGetter.auth('email address', 'password')
>>> CheddarGetter.set_product_code('product code')

Get a list of customers:

>>> for customer in Customer.all():
...     print customer.last_name

Edit a customer:

>>> customer = Customer.get('MY_CUSTOMER_CODE')
>>> customer.last_name = 'Jones'

Add a new customer:

>>> customer = Customer()
>>> customer.code = 'JOHN_SMITH'
>>> customer.first_name = 'John'
>>> customer.last_name = 'Smith'
>>> = ''
>>> customer.plan_code = 'FREE'

All of which work just like you would expect them to in Python. You can interact with Plan objects in the same way, to get and modify the account plans you have set up in CheddarGetter.

A customer's subscription information is just as easy to get at. To update the credit card information for a customer you just do this:

>>> customer = Customer.get('JOHN_SMITH')
>>> sub = customer.subscription
>>> sub.cc_number = '4111111111111111'
>>> sub.cc_first_name = 'John'
>>> sub.cc_last_name = 'Smith'
>>> sub.cc_expiration = '01/2013'
>>> sub.cc_zip = '77777'
>>> sub.cc_card_code = '000'

There are a lot more usage examples in the README on GitHub. We're not quite done writing PyCheddar - and are not using it on our production site yet - but we thought it was time to let people know about it in case anyone is starting a new project and looking to use CheddarGetter. We should be production ready, using it on, in a few weeks.

Django integration

With the objects already working a lot like Django models, we haven't really had to do much by way of Django integration to get it working with our site. We did build in one little bit of magic for you though. If you set the following in your


We'll handle authentication for you automatically so you can just get to work with the objects.

We believe in open source

PyCheddar was created as part of the code base for FeedMagnet. We spent our time writing it - which cost our little startup money in salaries and time. The old way of thinking about software would say that we should hold on to this as intellectual property - but we don't think that way.

We really believe in open source software. We've benefited a ton from it. We use Ubuntu, Python, Django, MySQL - and a bunch of other open source tools to make FeedMagnet run. We get to use those tools because other people before us have been kind enough to share their work with the public.

Open source only works if we all give back. This is hopefully just our first minor contribution to the open source community.

Get started using PyCheddar

If you are a developer and want to check out PyCheddar, you can get the latest version off GitHub:

$ easy_install httplib2
$ git clone

Or you can get it (and httplib2) off PyPi like this:

$ easy_install pycheddar

Best of luck with your web apps! Let us know if you want to contribute and help make PyCheddar even better.