Skip to content

Commit

Permalink
Stripe: Unidecode Statement Descriptor; unify allowed characters and …
Browse files Browse the repository at this point in the history
…symbols (#3825)

* Stripe: Unidecode Statement Descriptor; unify allowed characters and symbols

* Reverse str/unidecode order
  • Loading branch information
pc-coholic committed Jan 22, 2024
1 parent aad94f1 commit 0938bf3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pretix/plugins/stripe/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from django.utils.timezone import now
from django.utils.translation import gettext, gettext_lazy as _, pgettext
from django_countries import countries
from text_unidecode import unidecode

from pretix import __version__
from pretix.base.decimal import round_decimal
Expand Down Expand Up @@ -556,15 +557,15 @@ def statement_descriptor(self, payment, length=22):
# the postfix.
return '{code} {postfix}'.format(
code=payment.order.code,
postfix=re.sub('[^a-zA-Z0-9 ]', '', str(self.settings.postfix)),
postfix=re.sub("[^a-zA-Z0-9-_. ]", "", unidecode(str(self.settings.postfix))),
)[:length]
else:
# If no custom postfix is set, we transmit the event slug and event name for backwards compatibility
# with older pretix versions.
return '{event}-{code} {eventname}'.format(
event=self.event.slug.upper(),
code=payment.order.code,
eventname=re.sub('[^a-zA-Z0-9 ]', '', str(self.event.name))
eventname=re.sub("[^a-zA-Z0-9-_. ]", "", unidecode(str(self.event.name))),
)[:length]

@property
Expand Down

0 comments on commit 0938bf3

Please sign in to comment.