fix: record payment ref immediately; show it on admin request page
This commit is contained in:
parent
109ac6c0b2
commit
0aa3eab084
2 changed files with 8 additions and 2 deletions
7
app.py
7
app.py
|
|
@ -672,6 +672,9 @@ def admin_request(rid):
|
||||||
flash('Select at least one file to deliver.', 'error')
|
flash('Select at least one file to deliver.', 'error')
|
||||||
return redirect(url_for('admin_request', rid=rid))
|
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 = []
|
attachments = []
|
||||||
for path in selected:
|
for path in selected:
|
||||||
p = Path(path)
|
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']}"
|
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:
|
try:
|
||||||
send_email(req['email'], 'Your theme song files are here!', body, attachments=attachments, inline_images=build_signature_images())
|
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')
|
flash('Delivery email sent with MP3 attachments.', 'success')
|
||||||
except Exception as e:
|
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))
|
return redirect(url_for('admin_request', rid=rid))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,9 @@
|
||||||
<span class="status-badge missing">❌ Not sent yet</span>
|
<span class="status-badge missing">❌ Not sent yet</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
{% if req.square_payment_ref %}
|
||||||
|
<p><strong>Square Payment Reference:</strong> {{ req.square_payment_ref }}</p>
|
||||||
|
{% endif %}
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input type="hidden" name="action" value="mark_paid_deliver">
|
<input type="hidden" name="action" value="mark_paid_deliver">
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue