webhook tested locally
This commit is contained in:
@@ -28,10 +28,11 @@ def get_contacts(rower):
|
||||
if res.status_code != 200:
|
||||
return None
|
||||
|
||||
if len(res.json())==1:
|
||||
if len(res.json())>=1:
|
||||
r = res.json()[0]
|
||||
return r['id']
|
||||
|
||||
|
||||
return None
|
||||
|
||||
# this should be triggered on braintree payment
|
||||
@@ -54,6 +55,7 @@ def create_contact(rower):
|
||||
"web": ""
|
||||
}
|
||||
|
||||
|
||||
res = requests.post(contacts_url, data=json.dumps(post_data), auth=auth,headers=headers)
|
||||
|
||||
if res.status_code not in [200,201]:
|
||||
@@ -62,7 +64,7 @@ def create_contact(rower):
|
||||
return res.json()['id']
|
||||
|
||||
# this should be triggered by a Braintree webhook
|
||||
def create_invoice(rower,amount,braintreeid,send=False):
|
||||
def create_invoice(rower,amount,braintreeid,dosend=True):
|
||||
|
||||
r_id = get_contacts(rower)
|
||||
|
||||
@@ -75,17 +77,18 @@ def create_invoice(rower,amount,braintreeid,send=False):
|
||||
'language':'en',
|
||||
'payment_method': 'card',
|
||||
'currency': 'EUR',
|
||||
'paid_amount': amount,
|
||||
'paid_amount': str(amount),
|
||||
'status': 'paid',
|
||||
'lines': [{
|
||||
'name': 'Rowsandall Subscription',
|
||||
'quantity': '1',
|
||||
'unit_price': amount,
|
||||
'unit_price': str(amount),
|
||||
'vat_rate': 0,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
res = requests.post(invoices_url, data=json.dumps(post_data), auth=auth,headers=headers)
|
||||
|
||||
if res.status_code not in [200,201]:
|
||||
@@ -107,7 +110,7 @@ def create_invoice(rower,amount,braintreeid,send=False):
|
||||
if res.status_code not in [200,201]:
|
||||
return 0
|
||||
|
||||
if send:
|
||||
if dosend:
|
||||
res = requests.post(urlsend,auth=auth,headers=headers)
|
||||
|
||||
return id
|
||||
|
||||
Reference in New Issue
Block a user