From 0aa3eab0845bdc58c95c418a6c8dcb7d2cf6fc24 Mon Sep 17 00:00:00 2001
From: "Troll (Hermes Agent)"
Date: Sun, 2 Aug 2026 23:23:45 +0000
Subject: [PATCH] fix: record payment ref immediately; show it on admin request
page
---
app.py | 7 +++++--
templates/admin/request.html | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/app.py b/app.py
index 69736ae..c7f5673 100644
--- a/app.py
+++ b/app.py
@@ -672,6 +672,9 @@ def admin_request(rid):
flash('Select at least one file to deliver.', 'error')
return redirect(url_for('admin_request', rid=rid))
+ # Record payment immediately so the reference is preserved even if email fails.
+ update_request(rid, square_payment_ref=payment_ref, status='delivered')
+
attachments = []
for path in selected:
p = Path(path)
@@ -682,10 +685,10 @@ def admin_request(rid):
body = f"Hi {req['name']},\n\nThanks for your payment! Your selected song(s) are attached to this email.\n\nYou can also keep streaming them here: {player_link}\n\nEnjoy!\n\nā {current_app.config['BOOTH_NAME']}"
try:
send_email(req['email'], 'Your theme song files are here!', body, attachments=attachments, inline_images=build_signature_images())
- update_request(rid, square_payment_ref=payment_ref, delivery_sent_at=now_utc(), status='delivered')
+ update_request(rid, delivery_sent_at=now_utc())
flash('Delivery email sent with MP3 attachments.', 'success')
except Exception as e:
- flash(f'Failed to send delivery email: {e}', 'error')
+ flash(f'Payment recorded, but delivery email failed: {e}', 'error')
return redirect(url_for('admin_request', rid=rid))
diff --git a/templates/admin/request.html b/templates/admin/request.html
index 8bb06da..92905ed 100644
--- a/templates/admin/request.html
+++ b/templates/admin/request.html
@@ -279,6 +279,9 @@
ā Not sent yet
{% endif %}
+ {% if req.square_payment_ref %}
+ Square Payment Reference: {{ req.square_payment_ref }}
+ {% endif %}