Last active
August 29, 2015 14:27
-
-
Save fxdgear/41d790004b8590731bc4 to your computer and use it in GitHub Desktop.
python recurly token generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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