From 2824b40299336d4aedd25ec98ca5f8383c056c95 Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Mon, 18 Nov 2024 15:03:32 +0100 Subject: [PATCH] Stripe: Add MobilePay as a supported payment method (Z#23172523) (#4635) Co-authored-by: robbi5 --- src/pretix/plugins/stripe/payment.py | 25 ++++++++++++++++++++++++- src/pretix/plugins/stripe/signals.py | 6 +++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/pretix/plugins/stripe/payment.py b/src/pretix/plugins/stripe/payment.py index 3f54e345a2..7eebd17318 100644 --- a/src/pretix/plugins/stripe/payment.py +++ b/src/pretix/plugins/stripe/payment.py @@ -152,7 +152,7 @@ logger = logging.getLogger('pretix.plugins.stripe') # - Link: ✓ (PaymentRequestButton) # - Cash App Pay: ✗ # - PayPal: ✓ (No settings UI yet) -# - MobilePay: ✗ +# - MobilePay: ✓ # - Alipay: ✓ # - WeChat Pay: ✓ # - GrabPay: ✓ @@ -494,6 +494,11 @@ class StripeSettingsHolder(BasePaymentProvider): # 'EUR', 'GBP', 'USD', 'CHF', 'CZK', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'CAD', 'HKD', 'NZD', 'SGD' # ] # )), + ('method_mobilepay', + forms.BooleanField( + label=_('MobilePay'), + disabled=self.event.currency not in ['DKK', 'EUR', 'NOK', 'SEK'], + )), ] + extra_fields + list(super().settings_form_fields.items()) + moto_settings ) if not self.settings.connect_client_id or self.settings.secret_key: @@ -1853,3 +1858,21 @@ class StripeTwint(StripeRedirectMethod): "type": "twint", }, } + + +class StripeMobilePay(StripeRedirectMethod): + identifier = 'stripe_mobilepay' + verbose_name = 'MobilePay via Stripe' + public_name = 'MobilePay' + method = 'mobilepay' + confirmation_method = 'automatic' + explanation = _( + 'This payment method is available to MobilePay app users in Denmark and Finland. Please have your app ready.' + ) + + def _payment_intent_kwargs(self, request, payment): + return { + "payment_method_data": { + "type": "mobilepay", + }, + } diff --git a/src/pretix/plugins/stripe/signals.py b/src/pretix/plugins/stripe/signals.py index bf6dc08533..29189b7d28 100644 --- a/src/pretix/plugins/stripe/signals.py +++ b/src/pretix/plugins/stripe/signals.py @@ -46,8 +46,8 @@ from pretix.presale.signals import html_head, process_response def register_payment_provider(sender, **kwargs): from .payment import ( StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS, - StripeGiropay, StripeIdeal, StripeKlarna, StripeMultibanco, - StripePayPal, StripePrzelewy24, StripeRevolutPay, + StripeGiropay, StripeIdeal, StripeKlarna, StripeMobilePay, + StripeMultibanco, StripePayPal, StripePrzelewy24, StripeRevolutPay, StripeSEPADirectDebit, StripeSettingsHolder, StripeSofort, StripeSwish, StripeTwint, StripeWeChatPay, ) @@ -55,7 +55,7 @@ def register_payment_provider(sender, **kwargs): return [ StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact, StripeSofort, StripeEPS, StripeMultibanco, StripePrzelewy24, StripeRevolutPay, StripeWeChatPay, - StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish, StripeTwint, + StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish, StripeTwint, StripeMobilePay ]