Do not sent "payment failed" email if payment is no longer expected (Z#23202699) (#5509)

This commit is contained in:
Raphael Michel
2025-10-06 09:24:20 +02:00
committed by GitHub
parent 25f57f89b0
commit 7e8da3cef6

View File

@@ -1840,6 +1840,10 @@ class OrderPayment(models.Model):
)) ))
return False return False
if locked_instance.state == OrderPayment.PAYMENT_STATE_CANCELED:
# Never send mails when the payment was already canceled intentionally
send_mail = False
if isinstance(info, str): if isinstance(info, str):
locked_instance.info = info locked_instance.info = info
elif info: elif info:
@@ -1855,6 +1859,10 @@ class OrderPayment(models.Model):
'data': log_data, 'data': log_data,
}, user=user, auth=auth) }, user=user, auth=auth)
if self.order.status in (Order.STATUS_PAID, Order.STATUS_CANCELED, Order.STATUS_EXPIRED):
# No reason to send mail, as the payment is no longer really expected
send_mail = False
if send_mail: if send_mail:
with language(self.order.locale, self.order.event.settings.region): with language(self.order.locale, self.order.event.settings.region):
email_subject = self.order.event.settings.mail_subject_order_payment_failed email_subject = self.order.event.settings.mail_subject_order_payment_failed