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: ✗ # - PayNow: ✗
# - UPI: ✗ # - UPI: ✗
# - Netbanking: ✗ # - Netbanking: ✗
# - TWINT: ✓
# #
# Bank transfers # Bank transfers
# - ACH Bank Transfer: ✗ # - ACH Bank Transfer: ✗
@@ -448,6 +449,14 @@ class StripeSettingsHolder(BasePaymentProvider):
'before they work properly.'), 'before they work properly.'),
required=False, 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', ('method_affirm',
forms.BooleanField( forms.BooleanField(
label=_('Affirm'), 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",
},
}

View File

@@ -48,13 +48,14 @@ def register_payment_provider(sender, **kwargs):
StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS, StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS,
StripeGiropay, StripeIdeal, StripeKlarna, StripeMultibanco, StripeGiropay, StripeIdeal, StripeKlarna, StripeMultibanco,
StripePayPal, StripePrzelewy24, StripeSEPADirectDebit, StripePayPal, StripePrzelewy24, StripeSEPADirectDebit,
StripeSettingsHolder, StripeSofort, StripeSwish, StripeWeChatPay, StripeSettingsHolder, StripeSofort, StripeSwish, StripeTwint,
StripeWeChatPay,
) )
return [ return [
StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact, StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact,
StripeSofort, StripeEPS, StripeMultibanco, StripePrzelewy24, StripeWeChatPay, StripeSofort, StripeEPS, StripeMultibanco, StripePrzelewy24, StripeWeChatPay,
StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish, StripeTwint,
] ]