|
|
@@ -208,6 +208,8 @@ def gb_hook():
|
|
|
|
|
|
raw_data = request.get_data(as_text=True)
|
|
|
|
|
|
+ current_app.logger.debug(f'\n\n{raw_data}\n\n')
|
|
|
+
|
|
|
event = request.json
|
|
|
|
|
|
if signature == gb_secret:
|
|
|
@@ -215,12 +217,29 @@ def gb_hook():
|
|
|
try:
|
|
|
event_type = event['event']
|
|
|
if event_type == 'transaction.succeeded':
|
|
|
- transaction = event['data']
|
|
|
- from_name = f'{transaction["first_name"]} {transaction["last_name"]}'
|
|
|
- email = transaction['email']
|
|
|
- amount = transaction['amount']
|
|
|
- current_app.logger.debug(f'From: {from_name}\nEmail: {email}\nAmount: {amount}\n\n')
|
|
|
- donation_info = [True, from_name, email, amount, '']
|
|
|
+ data = event['data']
|
|
|
+ custom_fields = data["custom_fields"]
|
|
|
+ if custom_fields:
|
|
|
+ for field in custom_fields: # Get anonymous donation custom field, if it's there'
|
|
|
+ if field['title'].lower() == 'anonymous':
|
|
|
+ if field['value'].lower() == "yes":
|
|
|
+ is_public = False
|
|
|
+ current_app.logger.info(f'Donation is anonymous.')
|
|
|
+ else:
|
|
|
+ is_public = True
|
|
|
+ current_app.logger.info(f'Donation is not anonymous.')
|
|
|
+ else: # If it's not there, set to anonymous
|
|
|
+ is_public = False
|
|
|
+ current_app.logger.info(f'No anoymous donation custom field found. Assuming anonymous')
|
|
|
+ else: # No custom fields found, set to anonymous
|
|
|
+ is_public = False
|
|
|
+ current_app.logger.info(f'No custom fields found. Assuming anonymous')
|
|
|
+
|
|
|
+ from_name = f'{data["first_name"]} {data["last_name"]}'
|
|
|
+ email = data['email']
|
|
|
+ amount = data['amount']
|
|
|
+ current_app.logger.debug(f'\nFrom: {from_name}\nEmail: {email}\nAmount: {amount}\nAnonymous: {is_public}\n\n')
|
|
|
+ donation_info = [is_public, from_name, email, amount, '']
|
|
|
donation_points = current_app.config['GB_SETTINGS']['donation_points']
|
|
|
points_for_donations = current_app.config['GB_SETTINGS']['donations']
|
|
|
if points_for_donations: # Are we giving points for donations?
|