make_post_sell/fix_stuck_refund.sql
Russell Ballestrini f58bd3e628 Add email deduplication to prevent duplicate crypto payment emails
- Add sales_email_sent, purchase_email_sent, refund_email_sent columns to CryptoPayment model
- Update finalize_invoice to check email flags before sending confirmation emails
- Add alembic migration for new email tracking columns
- Update CLAUDE.md with database safety warnings
2025-09-26 13:48:36 -04:00

27 lines
No EOL
1,009 B
SQL

-- Fix the payment that had a successful refund but missing transaction hash
-- Payment ID: a7d015e7-9adf-11f0-a73e-02dfe05770ee
-- Refund TX: 86797dcc2f1a32a23142199844470b4890d8137421bb1e647608add9783c5e2a
-- Refund amount: 0.00156780318058 XMR = 1567803180 piconero
UPDATE mps_crypto_payment
SET
refund_tx_hash = '86797dcc2f1a32a23142199844470b4890d8137421bb1e647608add9783c5e2a',
refund_amount = 1567803180,
refund_reason = 'Underpayment: received 0.001722860638 but expected 0.003628767358',
status = 'underpaid-refunded-complete',
updated_timestamp = CAST(strftime('%s', 'now') AS INTEGER) * 1000
WHERE
id = 'a7d015e7-9adf-11f0-a73e-02dfe05770ee'
AND status = 'underpaid-refunded'
AND refund_tx_hash IS NULL;
-- Verify the update
SELECT
id,
status,
refund_tx_hash,
refund_amount,
refund_reason,
datetime(updated_timestamp/1000, 'unixepoch', 'localtime') as updated_at
FROM mps_crypto_payment
WHERE id = 'a7d015e7-9adf-11f0-a73e-02dfe05770ee';