Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy-pi/c1f1c4c1163a8699361ec210e2800307 to your computer and use it in GitHub Desktop.
Save andy-pi/c1f1c4c1163a8699361ec210e2800307 to your computer and use it in GitHub Desktop.
List all your chargify customers, and find the subscription id, given an email address
from chargify import Chargify # import this module https://github.com/hindsightlabs/chargify-python
CHARGIFY_API_KEY="MY_API_KEY" # insert your api key here
CHARGIFY_SUBDOMAIN="MY_SUBDOMAIN" # insert your subdomain here
chargify = Chargify(CHARGIFY_API_KEY,CHARGIFY_SUBDOMAIN)
def get_subscription_id_from_Chargify(email):
'''
Interface with chargify API to get their subscription_id, given a customer email address
'''
partial_list = chargify.customers() # Get the first 50 customers
customerlist = partial_list
i=2
while len(partial_list)==50:
partial_list = chargify.customers(page=i) # Gets the next page of 50, if the previous list was the max (50)
customerlist = customerlist + partial_list # Add the next page to the complete list
i=i+1
for customer in customerlist:
if (customer["customer"]["email"]==email):
subscription_id = customer["customer"]["id"]
# Need to add an error handler if search does not return results
return subscription_id
if __name__ == "__main__":
email="me@me.com"
subscription_id=get_subscription_id_from_Chargify(email)
print email +"'s Chargify subscription id is: " + subscription_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment