Prevent duplicate payment confirmation mails

This commit is contained in:
Raphael Michel
2017-01-22 17:46:56 +01:00
parent 04369ff4f1
commit 221526c979
3 changed files with 11 additions and 2 deletions

View File

@@ -85,6 +85,9 @@ def mark_order_paid(order: Order, provider: str=None, info: str=None, date: date
:type mail_text: str
:raises Quota.QuotaExceededException: if the quota is exceeded and ``force`` is ``False``
"""
if order.status == Order.STATUS_PAID:
return order
with order.event.lock() as now_dt:
can_be_paid = order._can_be_paid()
if not force and can_be_paid is not True:

View File

@@ -8,7 +8,7 @@ from django.contrib import messages
from django.template.loader import get_template
from django.utils.translation import ugettext as __, ugettext_lazy as _
from pretix.base.models import Quota, RequiredAction
from pretix.base.models import Order, Quota, RequiredAction
from pretix.base.payment import BasePaymentProvider
from pretix.base.services.mail import SendMailException
from pretix.base.services.orders import mark_order_paid, mark_order_refunded
@@ -199,6 +199,10 @@ class Paypal(BasePaymentProvider):
logger.error('Invalid state: %s' % str(payment))
return
if order.status == Order.STATUS_PAID:
logger.warning('PayPal success event even though order is already marked as paid')
return
try:
mark_order_paid(order, 'paypal', json.dumps(payment.to_dict()))
except Quota.QuotaExceededException as e:

View File

@@ -42,8 +42,10 @@ class CartActionMixin:
amount = int(value)
except ValueError:
raise CartError(_('Please enter numbers only.'))
if amount <= 0:
if amount < 0:
raise CartError(_('Please enter positive numbers only.'))
elif amount == 0:
return
price = self.request.POST.get('price_' + "_".join(parts[1:]), "")
if key.startswith('item_'):