Skip to content

Instantly share code, notes, and snippets.

@fxdgear
Last active August 29, 2015 14:27
Show Gist options
  • Save fxdgear/41d790004b8590731bc4 to your computer and use it in GitHub Desktop.
Save fxdgear/41d790004b8590731bc4 to your computer and use it in GitHub Desktop.
python recurly token generator
import os
import requests
def get_recurly_token(billing_data):
billing_data.update(**{
'version': "3.1.0",
'key': os.environ.get('RECURLY_PUBLIC_KEY')
})
recurly_js_url = "https://api.recurly.com/js/v1/token"
response = requests.get(recurly_js_url, params=billing_data)
data = response.json()
if data.get('id', None):
return data['id']
else:
print(response.status_code, data)
raise ValueError('unable to get recurly_id')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment