commit a02fb7d721b99fb31e87c0314266ded8bdd66a71
parent ff05b3191d92c2bc550c710648f68a0a81abf2f7
Author: NicholasFarrow <nicholas.w.farrow@gmail.com>
Date: Fri, 15 Jan 2021 14:00:57 +1100
cleanup
Diffstat:
M | server.py | | | 39 | ++++++++++++++++----------------------- |
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/server.py b/server.py
@@ -22,7 +22,7 @@ socket_ = SocketIO(app, async_mode=async_mode, cors_allowed_origins="*")
# To-do, this will be a donation form page that submits to /pay
@app.route('/')
def index():
- return render_template('index.html', async_mode=socket_.async_mode)
+ return render_template('donate.html', async_mode=socket_.async_mode)
@app.route('/pay')
def payment_page():
@@ -75,30 +75,23 @@ def make_payment(payload):
payment.response = 'Payment finalised. Thankyou!'
update_status(payment)
- print("ABOUT TO WEBHOOOK")
- payment.status = payload['webhook_url']
- payment.response = payload['webhook_url']
- update_status(payment)
-
-
# Call webhook
- print("PAYLOADDDDDDDDDDDDDDDDDDDDD")
- print({'id' : payload['id']})
- response = requests.get(
- payload['webhook_url'], params={'id' : payload['id']},
- headers={'Content-Type': 'application/json'}
- )
- if response.status_code != 200:
- print('Failed to confirm payment via webhook {}, the response is: {}'.format(response.status_code, response.text))
- payment.status = response.text
- payment.response = response.text
- else:
- print("Successfully confirmed payment via webhook.")
- payment.status = 'HOOKED'
- payment.response = 'HOOKED'
+ if config.gateway is not None and config.gateway:
+ response = requests.get(
+ payload['w_url'], params={'id' : payload['id']},
+ headers={'Content-Type': 'application/json'}
+ )
+ if response.status_code != 200:
+ print('Failed to confirm payment via webhook {}, the response is: {}'.format(response.status_code, response.text))
+ payment.status = response.text
+ payment.response = response.text
+ else:
+ print("Successfully confirmed payment via webhook.")
+ payment.status = 'Payment confirmed.'
+ payment.response = 'Payment confirmed.'
+
+ update_status(payment)
- update_status(payment)
- print("Done response part...")
### DO SOMETHING
# Depends on config
# Get redirected?