diff --git a/make_post_sell/lib/mail.py b/make_post_sell/lib/mail.py index 2076062..5cf97ca 100644 --- a/make_post_sell/lib/mail.py +++ b/make_post_sell/lib/mail.py @@ -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""" + +
+{explanation}
+ +| Payment Amount: | +{received_amount} {crypto_payment.coin_type} | +
| Payment ID: | +{crypto_payment.id} | +