Stripe: Support for TWINT (#4216)

* Stripe: Support for TWINT

* Update src/pretix/plugins/stripe/payment.py

Co-authored-by: Richard Schreiber <schreiber@rami.io>

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2024-06-20 10:22:43 +02:00
committed by GitHub
parent ce06672334
commit 7338381e58
2 changed files with 34 additions and 2 deletions

View File

@@ -116,6 +116,7 @@ logger = logging.getLogger('pretix.plugins.stripe')
# - PayNow: ✗
# - UPI: ✗
# - Netbanking: ✗
# - TWINT: ✓
#
# Bank transfers
# - ACH Bank Transfer: ✗
@@ -448,6 +449,14 @@ class StripeSettingsHolder(BasePaymentProvider):
'before they work properly.'),
required=False,
)),
('method_twint',
forms.BooleanField(
label='TWINT',
disabled=self.event.currency != 'CHF',
help_text=_('Some payment methods might need to be enabled in the settings of your Stripe account '
'before they work properly.'),
required=False,
)),
('method_affirm',
forms.BooleanField(
label=_('Affirm'),
@@ -1793,3 +1802,25 @@ class StripeSwish(StripeRedirectMethod):
},
}
}
class StripeTwint(StripeRedirectMethod):
identifier = 'stripe_twint'
verbose_name = _('TWINT via Stripe')
public_name = 'TWINT'
method = 'twint'
confirmation_method = 'automatic'
explanation = _(
'This payment method is available to users of the Swiss app TWINT. Please have your app '
'ready.'
)
def is_allowed(self, request: HttpRequest, total: Decimal=None) -> bool:
return super().is_allowed(request, total) and request.event.currency == "CHF" and total <= Decimal("5000.00")
def _payment_intent_kwargs(self, request, payment):
return {
"payment_method_data": {
"type": "twint",
},
}