Private
Public Access
1
0

logging for braintree

This commit is contained in:
Sander Roosendaal
2021-02-03 18:05:16 +01:00
parent 423e8c920c
commit 1f8dfc190c
3 changed files with 32 additions and 1 deletions

View File

@@ -67,6 +67,8 @@ def create_contact(rower):
def create_invoice(rower,amount,braintreeid,dosend=True):
r_id = get_contacts(rower)
with open('braintreewebhooks.log','a') as f:
f.write('Creating invoice for contact iD '+str(r_id)+'\n')
if not r_id:
return 0
@@ -90,6 +92,8 @@ def create_invoice(rower,amount,braintreeid,dosend=True):
res = requests.post(invoices_url, data=json.dumps(post_data), auth=auth,headers=headers)
with open('braintreewebhooks.log','a') as f:
f.write('Invoice Created - status code '+str(res.status_code)+'\n')
if res.status_code not in [200,201]:
return 0
@@ -107,12 +111,18 @@ def create_invoice(rower,amount,braintreeid,dosend=True):
res = requests.post(urlpay,auth=auth,headers=headers)
with open('braintreewebhooks.log','a') as f:
f.write('Invoice Set to paid - status code '+str(res.status_code)+'\n')
if res.status_code not in [200,201]:
return 0
if dosend:
res = requests.post(urlsend,auth=auth,headers=headers)
with open('braintreewebhooks.log','a') as f:
f.write('Invoice Sent - status code '+str(res.status_code)+'\n')
return id
#curl -u vas@email.cz:API_TOKEN -H 'User-Agent: YourApp (yourname@example.com)' \