From 33d1b47c5ad1f959245bc4af376ff45879677f1f Mon Sep 17 00:00:00 2001 From: Lukas Bockstaller Date: Thu, 13 Aug 2026 12:39:15 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: pajowu --- src/pretix/base/payment.py | 2 +- src/pretix/plugins/paypal2/payment.py | 10 +++------- .../templates/pretixplugins/paypal2/pending.html | 2 +- src/pretix/plugins/paypal2/views.py | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/pretix/base/payment.py b/src/pretix/base/payment.py index 7940794ebe..b0351a330d 100644 --- a/src/pretix/base/payment.py +++ b/src/pretix/base/payment.py @@ -1037,7 +1037,7 @@ class BasePaymentProvider: if payment.state == OrderPayment.PAYMENT_STATE_PENDING: if not self.payment_abort_pending_allowed(payment): raise PaymentException(_( - "This payment is already being processed and can not be canceled any more." + "This payment is already being processed and cannot be canceled any more." )) payment.state = OrderPayment.PAYMENT_STATE_CANCELED diff --git a/src/pretix/plugins/paypal2/payment.py b/src/pretix/plugins/paypal2/payment.py index 51080ab4f3..4dc85e01b6 100644 --- a/src/pretix/plugins/paypal2/payment.py +++ b/src/pretix/plugins/paypal2/payment.py @@ -199,7 +199,7 @@ class PaypalSettingsHolder(BasePaymentProvider): help_text=_( 'PayPals fraud prevention might block processing of individual payments for a considerable amount ' 'of time. The payment is marked as "pending" during this time window. You can allow your customers to ' - 'start another payment attempts during that window. This might result in overpayment of orders if the' + 'start another payment attempts during that window. This might result in them being charged twice if the' 'original payment is approved.' ), required=False @@ -893,11 +893,7 @@ class PaypalMethod(BasePaymentProvider): def payment_pending_render(self, request, payment) -> str: stuck_in_compliance = False - retry = True - - if payment.state == OrderPayment.PAYMENT_STATE_PENDING: - retry = self.abort_pending_payment_allowed(payment) and self.abort_pending_allowed - + retry = self.payment_abort_pending_allowed(payment) try: if ( payment.info @@ -908,7 +904,7 @@ class PaypalMethod(BasePaymentProvider): pass try: - if payment.info and payment.info_data['status'] == "APPROVED": + if payment.info_data.get('status') == "APPROVED": stuck_in_compliance = True except (KeyError): pass diff --git a/src/pretix/plugins/paypal2/templates/pretixplugins/paypal2/pending.html b/src/pretix/plugins/paypal2/templates/pretixplugins/paypal2/pending.html index 24bfe6e683..83f1c210c8 100644 --- a/src/pretix/plugins/paypal2/templates/pretixplugins/paypal2/pending.html +++ b/src/pretix/plugins/paypal2/templates/pretixplugins/paypal2/pending.html @@ -11,7 +11,7 @@ Your payment is being processed by PayPal. This takes longer than usual. You can wait until PayPal acknowledges the payment or you can try paying again with this or another payment method. This might result in you being charged twice in case PayPal allows your initial payment attempt. - Please contact us, to resolve this case. + Please contact us to resolve this case. {% endblocktrans %}

{% endif %} {% else %} diff --git a/src/pretix/plugins/paypal2/views.py b/src/pretix/plugins/paypal2/views.py index b1d172bccb..0177a65856 100644 --- a/src/pretix/plugins/paypal2/views.py +++ b/src/pretix/plugins/paypal2/views.py @@ -493,9 +493,9 @@ def webhook(request, *args, **kwargs): prov.log_payment_duration(payment) except Quota.QuotaExceededException: pass - if any_pending_review: + if any_pending_review and payment.state != OrderPayment.PAYMENT_STATE_PENDING: payment.state = OrderPayment.PAYMENT_STATE_PENDING - payment.save() + payment.save(update_fields=['state']) elif sale['status'] == 'APPROVED': try: request.session['payment_paypal_oid'] = payment.info_data['id']