CheddarGetter for Python and Django

15 views
Skip to first unread message

Social Network in DJango

unread,
Feb 14, 2010, 4:03:23 PM2/14/10
to pinax-business
Hey Guys,

I'm collecting different solutions that I have been running across in
the hopes that someone will share their experiences and insights on
which is most suitable for a monthly recurring subscription model
(think a dating site as a metaphor or a signup for an on-line learning
class).

Thank you in advance,

Jonathan
-------------------------------------------------------------------------------------------------------------------------
blog/cheddargetter-for-python-and-django/

CheddarGetter for Python and Django

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'
>>> customer.save()

Add a new customer:

>>> customer = Customer()
>>> customer.code = 'JOHN_SMITH'
>>> customer.first_name = 'John'
>>> customer.last_name = 'Smith'
>>> customer.email = 'john....@gmail.com'
>>> customer.plan_code = 'FREE'
>>> customer.save()

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'
>>> sub.save()

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
FeedMagnet.com, 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 settings.py:

* CHEDDARGETTER_USERNAME
* CHEDDARGETTER_PASSWORD
* CHEDDARGETTER_PRODUCT_CODE

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 g...@github.com:jasford/pycheddar.git

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.

Suno Ano

unread,
Feb 15, 2010, 5:22:56 AM2/15/10
to pinax-business
Hello Jonathan,

1)
I am very intersted in this kind of functionallity too. However, it
would only make sense to have a generic solution and thus a
commerce_project project template in Pinax. How to get there and
what's needed is, afaict, up for discussion.

2)
Please use your realname when posting. Also, include some URL to other
sites (CheddarGetter in this example) but don't post the entire
description.

3)
About CheddarGetter and thus the way on moving forward on some
commerce_project project template in Pinax. I think, from all the
solutions I've seen to this point, using CheddarGetter sounds like a
reasonable thing to me. Things like Harley Bussell's amazing melt of
Satchmo and Pinax's social_project might then use (read shift to it)
sooner or later.

What do the rest of you guys think about that as a basic tune/
direction to some commerce_project in Pinax. I think we can agree on
the fact that what for example Harley build is already to specific ...
a shop imo would be one possible manifestation of Pinax's yet to be
done commerce_project substrate. Maybe including something like
CheddarGetter into Pinax basic_project could already qualify for a
commerce_project yes?

On Feb 14, 10:03 pm, Social Network in DJango <readb...@gmail.com>
wrote:

> >>> customer.email = 'john.sm...@gmail.com'

bobhaugen

unread,
Feb 15, 2010, 7:19:10 AM2/15/10
to pinax-business
On Feb 15, 4:22 am, Suno Ano <suno....@sunoano.org> wrote:
> What do the rest of you guys think about that as a basic tune/
> direction to some commerce_project in Pinax. I think we can agree on
> the fact that what for example Harley build is already to specific ...
> a shop imo would be one possible manifestation of Pinax's yet to be
> done commerce_project substrate. Maybe including something like
> CheddarGetter into Pinax basic_project could already qualify for a
> commerce_project yes?

All depends on the business model of the site, or, what do you mean by
Pinax commerce. The first couple of threads in this list started to
explore that question:
http://groups.google.com/group/pinax-business/browse_thread/thread/5897a2f8586b38bf?hl=en
http://groups.google.com/group/pinax-business/browse_thread/thread/415c539b472ef308?hl=en

I just started another one here:
http://groups.google.com/group/pinax-business/t/ce80f838bbee1da2?hl=en

Reply all
Reply to author
Forward
0 new messages