Compare commits

...

6 Commits

Author SHA1 Message Date
Richard Schreiber
a25bca7471 Fix static instance name in emails (Z#23224360) (#5914) 2026-02-25 13:19:53 +01:00
luelista
da43984ad2 Add datasync logging (Z#23225588) (#5928)
* Fix inconsistent log messages

* Add logging for successfully synced orders

(debugging orders that might get silently skipped)
2026-02-25 09:49:52 +01:00
Martin Gross
7cce1c9219 PPv2: Handle paypal-payments/oders in 'created' status (Z#23225625) (#5929) 2026-02-25 09:21:58 +01:00
Martin Gross
cb9c4466f9 Revert "PPv2: Do not put payments in pending-state if no capture has occured yet."
This reverts commit e5c8f19984.
2026-02-24 16:55:57 +01:00
Martin Gross
3398cda74b PPv2: properly check for pending-payments in pending-renderer 2026-02-24 16:16:22 +01:00
Martin Gross
e5c8f19984 PPv2: Do not put payments in pending-state if no capture has occured yet. 2026-02-24 16:07:16 +01:00
12 changed files with 46 additions and 31 deletions

View File

@@ -365,9 +365,10 @@ class TeamInviteSerializer(serializers.ModelSerializer):
def _send_invite(self, instance): def _send_invite(self, instance):
mail( mail(
instance.email, instance.email,
_('pretix account invitation'), _('Account invitation'),
'pretixcontrol/email/invitation.txt', 'pretixcontrol/email/invitation.txt',
{ {
'instance': settings.PRETIX_INSTANCE_NAME,
'user': self, 'user': self,
'organizer': self.context['organizer'].name, 'organizer': self.context['organizer'].name,
'team': instance.team.name, 'team': instance.team.name,

View File

@@ -216,7 +216,10 @@ class OutboundSyncProvider:
try: try:
mapped_objects = self.sync_order(sq.order) mapped_objects = self.sync_order(sq.order)
if not all(all(not res or res.sync_info.get("action", "") == "nothing_to_do" for res in res_list) for res_list in mapped_objects.values()): actions_taken = [res and res.sync_info.get("action", "") for res_list in mapped_objects.values() for res in res_list]
should_write_logentry = any(action not in (None, "nothing_to_do") for action in actions_taken)
logger.info('Synced order %s to %s, actions: %r, log: %r', sq.order.code, sq.sync_provider, actions_taken, should_write_logentry)
if should_write_logentry:
sq.order.log_action("pretix.event.order.data_sync.success", { sq.order.log_action("pretix.event.order.data_sync.success", {
"provider": self.identifier, "provider": self.identifier,
"objects": { "objects": {
@@ -237,7 +240,7 @@ class OutboundSyncProvider:
sq.set_sync_error("exceeded", e.messages, e.full_message) sq.set_sync_error("exceeded", e.messages, e.full_message)
else: else:
logger.info( logger.info(
f"Could not sync order {sq.order.code} to {type(self).__name__} " f"Could not sync order {sq.order.code} to {sq.sync_provider} "
f"(transient error, attempt #{sq.failed_attempts}, next {sq.not_before})", f"(transient error, attempt #{sq.failed_attempts}, next {sq.not_before})",
exc_info=True, exc_info=True,
) )

View File

@@ -346,7 +346,8 @@ class User(AbstractBaseUser, PermissionsMixin, LoggingMixin):
{ {
'user': self, 'user': self,
'messages': msg, 'messages': msg,
'url': build_absolute_uri('control:user.settings') 'url': build_absolute_uri('control:user.settings'),
'instance': settings.PRETIX_INSTANCE_NAME,
}, },
event=None, event=None,
user=self, user=self,
@@ -391,6 +392,7 @@ class User(AbstractBaseUser, PermissionsMixin, LoggingMixin):
'user': self, 'user': self,
'reason': msg, 'reason': msg,
'code': code, 'code': code,
'instance': settings.PRETIX_INSTANCE_NAME,
}, },
event=None, event=None,
user=self, user=self,
@@ -430,6 +432,7 @@ class User(AbstractBaseUser, PermissionsMixin, LoggingMixin):
mail( mail(
self.email, _('Password recovery'), 'pretixcontrol/email/forgot.txt', self.email, _('Password recovery'), 'pretixcontrol/email/forgot.txt',
{ {
'instance': settings.PRETIX_INSTANCE_NAME,
'user': self, 'user': self,
'url': (build_absolute_uri('control:auth.forgot.recover') 'url': (build_absolute_uri('control:auth.forgot.recover')
+ '?id=%d&token=%s' % (self.id, default_token_generator.make_token(self))) + '?id=%d&token=%s' % (self.id, default_token_generator.make_token(self)))

View File

@@ -86,7 +86,7 @@ class OrderSyncQueue(models.Model):
def set_sync_error(self, failure_mode, messages, full_message): def set_sync_error(self, failure_mode, messages, full_message):
logger.exception( logger.exception(
f"Could not sync order {self.order.code} to {type(self).__name__} ({failure_mode})" f"Could not sync order {self.order.code} to {self.sync_provider} ({failure_mode})"
) )
self.order.log_action(f"pretix.event.order.data_sync.failed.{failure_mode}", { self.order.log_action(f"pretix.event.order.data_sync.failed.{failure_mode}", {
"provider": self.sync_provider, "provider": self.sync_provider,

View File

@@ -176,6 +176,7 @@ def shred(self, event: Event, fileid: str, confirm_code: str, user: int=None, lo
_('Data shredding completed'), _('Data shredding completed'),
'pretixbase/email/shred_completed.txt', 'pretixbase/email/shred_completed.txt',
{ {
'instance': settings.PRETIX_INSTANCE_NAME,
'user': user, 'user': user,
'organizer': event.organizer.name, 'organizer': event.organizer.name,
'event': str(event.name), 'event': str(event.name),

View File

@@ -13,5 +13,5 @@ Start time: {{ start_time }} (new data added after this time might not have been
Best regards, Best regards,
Your pretix team Your {{ instance }} team
{% endblocktrans %} {% endblocktrans %}

View File

@@ -9,5 +9,5 @@ Please do never give this code to another person. Our support team will never as
If this code was not requested by you, please contact us immediately. If this code was not requested by you, please contact us immediately.
Best regards, Best regards,
Your pretix team Your {{ instance }} team
{% endblocktrans %} {% endblocktrans %}

View File

@@ -5,5 +5,5 @@ you requested a new password. Please go to the following page to reset your pass
{{ url }} {{ url }}
Best regards, Best regards,
Your pretix team Your {{ instance }} team
{% endblocktrans %} {% endblocktrans %}

View File

@@ -1,6 +1,6 @@
{% load i18n %}{% blocktrans with url=url|safe %}Hello, {% load i18n %}{% blocktrans with url=url|safe %}Hello,
you have been invited to a team on pretix, a platform to perform event you have been invited to a team on {{ instance }}, a platform to perform event
ticket sales. ticket sales.
Organizer: {{ organizer }} Organizer: {{ organizer }}
@@ -13,5 +13,5 @@ If you do not want to join, you can safely ignore or delete this email.
Best regards, Best regards,
Your pretix team Your {{ instance }} team
{% endblocktrans %} {% endblocktrans %}

View File

@@ -1,6 +1,6 @@
{% load i18n %}{% blocktrans with url=url|safe messages=messages|safe %}Hello, {% load i18n %}{% blocktrans with url=url|safe messages=messages|safe %}Hello,
this is to inform you that the account information of your pretix account has been this is to inform you that the account information of your {{ instance }} account has been
changed. In particular, the following changes have been performed: changed. In particular, the following changes have been performed:
{{ messages }} {{ messages }}
@@ -12,5 +12,5 @@ You can review and change your account settings here:
{{ url }} {{ url }}
Best regards, Best regards,
Your pretix team Your {{ instance }} team
{% endblocktrans %} {% endblocktrans %}

View File

@@ -1039,9 +1039,10 @@ class TeamMemberView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMixin,
def _send_invite(self, instance): def _send_invite(self, instance):
mail( mail(
instance.email, instance.email,
_('pretix account invitation'), _('Account invitation'),
'pretixcontrol/email/invitation.txt', 'pretixcontrol/email/invitation.txt',
{ {
'instance': settings.PRETIX_INSTANCE_NAME,
'user': self, 'user': self,
'organizer': self.request.organizer.name, 'organizer': self.request.organizer.name,
'team': instance.team.name, 'team': instance.team.name,

View File

@@ -802,31 +802,37 @@ class PaypalMethod(BasePaymentProvider):
all_captures_completed = False all_captures_completed = False
else: else:
any_captures = True any_captures = True
if not (any_captures and all_captures_completed):
# Payment has at least one capture, but it is not yet completed
if any_captures and not all_captures_completed:
messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as ' messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as '
'soon as the payment completed.')) 'soon as the payment completed.'))
payment.info = json.dumps(pp_captured_order.dict()) payment.info = json.dumps(pp_captured_order.dict())
payment.state = OrderPayment.PAYMENT_STATE_PENDING payment.state = OrderPayment.PAYMENT_STATE_PENDING
payment.save() payment.save()
return return
# Payment has at least one capture and all captures are completed
elif any_captures and all_captures_completed:
if pp_captured_order.status != 'COMPLETED':
payment.fail(info=pp_captured_order.dict())
logger.error('Invalid state: %s' % repr(pp_captured_order.dict()))
raise PaymentException(
_('We were unable to process your payment. See below for details on how to proceed.')
)
if pp_captured_order.status != 'COMPLETED': if payment.state == OrderPayment.PAYMENT_STATE_CONFIRMED:
payment.fail(info=pp_captured_order.dict()) logger.warning('PayPal success event even though order is already marked as paid')
logger.error('Invalid state: %s' % repr(pp_captured_order.dict())) return
raise PaymentException(
_('We were unable to process your payment. See below for details on how to proceed.')
)
if payment.state == OrderPayment.PAYMENT_STATE_CONFIRMED: try:
logger.warning('PayPal success event even though order is already marked as paid') payment.info = json.dumps(pp_captured_order.dict())
payment.save(update_fields=['info'])
payment.confirm()
except Quota.QuotaExceededException as e:
raise PaymentException(str(e))
# Payment has not any captures yet - so it's probably in created status
else:
return return
try:
payment.info = json.dumps(pp_captured_order.dict())
payment.save(update_fields=['info'])
payment.confirm()
except Quota.QuotaExceededException as e:
raise PaymentException(str(e))
finally: finally:
if 'payment_paypal_oid' in request.session: if 'payment_paypal_oid' in request.session:
del request.session['payment_paypal_oid'] del request.session['payment_paypal_oid']
@@ -836,7 +842,7 @@ class PaypalMethod(BasePaymentProvider):
try: try:
if ( if (
payment.info payment.info
and payment.info_data['purchase_units'][0]['payments']['captures'][0]['status'] == 'pending' and payment.info_data['purchase_units'][0]['payments']['captures'][0]['status'] == 'PENDING'
): ):
retry = False retry = False
except (KeyError, IndexError): except (KeyError, IndexError):