better
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from rowsandall_app.settings import (
|
from rowsandall_app.settings import (
|
||||||
FAKTUROID_EMAIL, FAKTUROID_API_KEY,
|
FAKTUROID_EMAIL, FAKTUROID_API_KEY,
|
||||||
@@ -21,7 +22,7 @@ headers = {
|
|||||||
|
|
||||||
def get_contacts(rower):
|
def get_contacts(rower):
|
||||||
res = requests.get(contacts_url, auth=auth, headers=headers)
|
res = requests.get(contacts_url, auth=auth, headers=headers)
|
||||||
url = contacts_search_url+'?query='+str(rower.user.email)
|
url = contacts_search_url+'?query='+urllib.parse.quote(rower.user.email)
|
||||||
with open('braintreewebhooks.log','a') as f:
|
with open('braintreewebhooks.log','a') as f:
|
||||||
f.write('Searching Contact url :'+str(url)+'\n')
|
f.write('Searching Contact url :'+str(url)+'\n')
|
||||||
|
|
||||||
@@ -81,17 +82,21 @@ def create_contact(rower):
|
|||||||
return res.json()['id']
|
return res.json()['id']
|
||||||
|
|
||||||
# this should be triggered by a Braintree webhook
|
# this should be triggered by a Braintree webhook
|
||||||
def create_invoice(rower,amount,braintreeid,dosend=True):
|
def create_invoice(rower,amount,braintreeid,dosend=True,
|
||||||
|
contact_id=None):
|
||||||
|
|
||||||
|
if not contact_id:
|
||||||
|
contact_id = get_contacts(rower)
|
||||||
|
|
||||||
|
|
||||||
r_id = get_contacts(rower)
|
|
||||||
with open('braintreewebhooks.log','a') as f:
|
with open('braintreewebhooks.log','a') as f:
|
||||||
f.write('Creating invoice for contact iD '+str(r_id)+'\n')
|
f.write('Creating invoice for contact iD '+str(contact_id)+'\n')
|
||||||
|
|
||||||
if not r_id:
|
if not contact_id:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
'subject_id': r_id,
|
'subject_id': contact_id,
|
||||||
'custom_id': braintreeid,
|
'custom_id': braintreeid,
|
||||||
'language':'en',
|
'language':'en',
|
||||||
'payment_method': 'card',
|
'payment_method': 'card',
|
||||||
|
|||||||
Reference in New Issue
Block a user