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')
|
||||
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))
|
||||
|
||||
|
|
|
|||
Reference in a new issue