Fix incorrect refund messaging for economically unviable payments
- Fix history page showing "refund pending" for underpaid-not-refunded status - Add specific condition for -not-refunded statuses before -refunded condition - Fix email templates to not show fee messages for no-refund cases - Economically unviable refunds now show payment details only, not refund details - Remove misleading "no fees deducted" message from no-refund scenarios
This commit is contained in:
parent
801cd7e595
commit
8038f8cf08
2 changed files with 58 additions and 7 deletions
|
|
@ -390,13 +390,16 @@ def send_refund_email(request, to_email, crypto_payment, refund_details):
|
|||
CryptoPayment.STATUS_DOUBLEPAY_NOT_REFUNDED,
|
||||
]:
|
||||
# Check if it's economically unviable vs no refund address
|
||||
if crypto_payment.refund_reason and "economically unviable" in crypto_payment.refund_reason:
|
||||
if (
|
||||
crypto_payment.refund_reason
|
||||
and "economically unviable" in crypto_payment.refund_reason
|
||||
):
|
||||
subject = f"Payment Issue - Refund Too Small - {crypto_payment.coin_type}"
|
||||
explanation = f"Your payment of {received_amount} {crypto_payment.coin_type} results in a refund amount too small to cover network transaction fees. The refund would cost more to send than its value."
|
||||
else:
|
||||
subject = f"Payment Issue - No Refund Address - {crypto_payment.coin_type}"
|
||||
explanation = "We were unable to process a refund for your payment because no refund address was configured."
|
||||
has_fee = False # No refund means no fee calculation
|
||||
has_fee = None # No refund means no fee message should be shown
|
||||
|
||||
else:
|
||||
subject = f"Refund Initiated - {crypto_payment.coin_type}"
|
||||
|
|
@ -404,13 +407,25 @@ def send_refund_email(request, to_email, crypto_payment, refund_details):
|
|||
has_fee = fee_amount > 0
|
||||
|
||||
# Set the fee note based on whether there's a fee
|
||||
if has_fee:
|
||||
if has_fee is None:
|
||||
fee_note = "" # No fee note for no-refund cases
|
||||
elif has_fee:
|
||||
fee_note = "A 9% restocking fee has been deducted to cover processing costs."
|
||||
else:
|
||||
fee_note = "No fees have been deducted - you will receive the full amount."
|
||||
|
||||
# Build the message text
|
||||
message_text = f"""{explanation}
|
||||
# Build the message text based on whether there's actually a refund
|
||||
if has_fee is None:
|
||||
# No refund case - don't show refund details
|
||||
message_text = f"""{explanation}
|
||||
|
||||
Payment Details:
|
||||
- Payment Amount: {received_amount} {crypto_payment.coin_type}
|
||||
- Payment ID: {crypto_payment.id}
|
||||
"""
|
||||
else:
|
||||
# Normal refund case - show refund details
|
||||
message_text = f"""{explanation}
|
||||
|
||||
Refund Details:
|
||||
- Original Payment: {received_amount} {crypto_payment.coin_type}
|
||||
|
|
@ -424,8 +439,33 @@ Refund Details:
|
|||
Please allow up to 10 confirmations for the refund to be fully processed.
|
||||
"""
|
||||
|
||||
# Build the HTML message
|
||||
message_html = f"""
|
||||
# Build the HTML message based on whether there's actually a refund
|
||||
if has_fee is None:
|
||||
# No refund case - simplified HTML
|
||||
message_html = f"""
|
||||
<html>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
||||
<h2>{subject}</h2>
|
||||
|
||||
<p>{explanation}</p>
|
||||
|
||||
<h3>Payment Details</h3>
|
||||
<table style="border-collapse: collapse; margin: 20px 0;">
|
||||
<tr>
|
||||
<td style="padding: 8px; font-weight: bold;">Payment Amount:</td>
|
||||
<td style="padding: 8px;">{received_amount} {crypto_payment.coin_type}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px; font-weight: bold;">Payment ID:</td>
|
||||
<td style="padding: 8px; font-family: monospace;">{crypto_payment.id}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
else:
|
||||
# Normal refund case - full HTML with refund details
|
||||
message_html = f"""
|
||||
<html>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
||||
<h2>{subject}</h2>
|
||||
|
|
|
|||
|
|
@ -91,6 +91,17 @@
|
|||
{% endif %}
|
||||
</small>
|
||||
</div>
|
||||
{% elif payment.status.endswith('-not-refunded') %}
|
||||
<div style="background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 3px; padding: 8px; margin-top: 10px;">
|
||||
<small>
|
||||
❌ No refund possible:
|
||||
{% if payment.refund_reason %}
|
||||
{{ payment.refund_reason }}
|
||||
{% else %}
|
||||
No refund address was configured, so funds were transferred to shop's cold storage.
|
||||
{% endif %}
|
||||
</small>
|
||||
</div>
|
||||
{% elif payment.status.endswith('-refunded') %}
|
||||
<div style="background: #d1ecf1; border: 1px solid #bee5eb; border-radius: 3px; padding: 8px; margin-top: 10px;">
|
||||
<small>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue