Stripe: Unidecode Statement Descriptor; unify allowed characters and symbols (#3825)

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

* Reverse str/unidecode order
This commit is contained in:
Martin Gross
2024-01-22 14:07:29 +01:00
committed by GitHub
parent aad94f1b2a
commit 0938bf3246

View File

@@ -55,6 +55,7 @@ from django.utils.safestring import mark_safe
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
@@ -556,7 +557,7 @@ class StripeMethod(BasePaymentProvider):
# 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
@@ -564,7 +565,7 @@ class StripeMethod(BasePaymentProvider):
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