Last active
June 12, 2018 20:14
-
-
Save DustinAlandzes/744961ea39170044036345b715d92bb4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requests | |
import json | |
class CoPilotAPI: | |
def __init__(base_url="https://accountsuat.cardconnect.com/", access_key, username, password): | |
self.base_url = "https://accountsuat.cardconnect.com/" | |
# load this from config file or environment variables | |
self.access_key = access_key | |
self.username = username | |
self.password = password | |
def get_access_key(): | |
''' | |
https://developer.cardconnect.com/copilotapi#get-access-token-endpoint | |
''' | |
endpoint = "https://accountsuat.cardconnect.com/" | |
data = { | |
"grant_type": "password", | |
"client_id": "copilot", | |
"client_secret": client_secret, | |
"username": username, | |
"password": password | |
} | |
headers = {"content-type": "application/x-www-form-urlencoded"} | |
r = requests.post(endpoint, data=data, headers=headers) | |
# probably need to do json.loads here | |
if 'error' in r.text: | |
throw Exception(r.text['error_description']) | |
return r.text['access_key'] | |
def make_merchant(): | |
''' | |
https://developer.cardconnect.com/copilotapi#create-merchant-endpoint | |
''' | |
print("not implemented yet") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment