Python CheddarGetter Client: cheddarsnake
While developing GainStudio there have been many cases where I’ve had to choose between implementing a system from scratch and relying on a pre-built component. One of the more obvious candidates for outsourcing was billing. Dealing with users’ private credit card data, subscription plan changes, and charge tracking are tasks that easily lend themselves to a separate system. After doing a lot of research, I settled on the excellent CheddarGetter to manage our subscription billing.
To get GainStudio talking to CheddarGetter, I wrote cheddarsnake, a Python wrapper around the CG API.
You can download cheddarsnake 0.2.6 here: cheddarsnake-0.2.6.tar.gz.
Example:
from cheddarsnake import CheddarGetter
cg = CheddarGetter('Your CG username','Your CG password','YOUR_PRODUCT_CODE')
# Get a customer using the customer code
cust = cg.customer('customer@company.com')
# See how many tracked items this customer has used
num = cust.subscriptions[0].items['ITEM_CODE'].quantity
Enjoy!