forked from CGM_Public/pretix_original
Stripe: Add support for Swish (#4149)
* Stripe: Add support for Swish * Update src/pretix/plugins/stripe/payment.py Co-authored-by: Martin Gross <gross@rami.io> --------- Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
@@ -133,7 +133,7 @@ logger = logging.getLogger('pretix.plugins.stripe')
|
|||||||
# - Zip: ✗
|
# - Zip: ✗
|
||||||
#
|
#
|
||||||
# Real-time payments
|
# Real-time payments
|
||||||
# - Swish: ✗
|
# - Swish: ✓
|
||||||
# - PayNow: ✗
|
# - PayNow: ✗
|
||||||
# - PromptPay: ✗
|
# - PromptPay: ✗
|
||||||
# - Pix: ✗
|
# - Pix: ✗
|
||||||
@@ -441,6 +441,14 @@ class StripeSettingsHolder(BasePaymentProvider):
|
|||||||
'before they work properly.'),
|
'before they work properly.'),
|
||||||
required=False,
|
required=False,
|
||||||
)),
|
)),
|
||||||
|
('method_swish',
|
||||||
|
forms.BooleanField(
|
||||||
|
label=_('Swish'),
|
||||||
|
disabled=self.event.currency != 'SEK',
|
||||||
|
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'),
|
||||||
@@ -1907,3 +1915,27 @@ class StripePayPal(StripeRedirectMethod):
|
|||||||
verbose_name = _('PayPal via Stripe')
|
verbose_name = _('PayPal via Stripe')
|
||||||
public_name = _('PayPal')
|
public_name = _('PayPal')
|
||||||
method = 'paypal'
|
method = 'paypal'
|
||||||
|
|
||||||
|
|
||||||
|
class StripeSwish(StripeRedirectMethod):
|
||||||
|
identifier = 'stripe_swish'
|
||||||
|
verbose_name = _('Swish via Stripe')
|
||||||
|
public_name = _('Swish')
|
||||||
|
method = 'swish'
|
||||||
|
confirmation_method = 'automatic'
|
||||||
|
explanation = _(
|
||||||
|
'This payment method is available to users of the Swedish apps Swish and BankID. Please have your app '
|
||||||
|
'ready.'
|
||||||
|
)
|
||||||
|
|
||||||
|
def _payment_intent_kwargs(self, request, payment):
|
||||||
|
return {
|
||||||
|
"payment_method_data": {
|
||||||
|
"type": "swish",
|
||||||
|
},
|
||||||
|
"payment_method_options": {
|
||||||
|
"swish": {
|
||||||
|
"reference": payment.order.full_code,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ 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, StripeWeChatPay,
|
StripeSettingsHolder, StripeSofort, StripeSwish, 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,
|
StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -599,7 +599,8 @@ class ScaView(StripeOrderView, View):
|
|||||||
return self._redirect_to_order()
|
return self._redirect_to_order()
|
||||||
|
|
||||||
if intent.status == 'requires_action' and intent.next_action.type in [
|
if intent.status == 'requires_action' and intent.next_action.type in [
|
||||||
'use_stripe_sdk', 'redirect_to_url', 'alipay_handle_redirect', 'wechat_pay_display_qr_code'
|
'use_stripe_sdk', 'redirect_to_url', 'alipay_handle_redirect', 'wechat_pay_display_qr_code',
|
||||||
|
'swish_handle_redirect_or_display_qr_code',
|
||||||
]:
|
]:
|
||||||
ctx = {
|
ctx = {
|
||||||
'order': self.order,
|
'order': self.order,
|
||||||
@@ -611,6 +612,9 @@ class ScaView(StripeOrderView, View):
|
|||||||
elif intent.next_action.type == 'redirect_to_url':
|
elif intent.next_action.type == 'redirect_to_url':
|
||||||
ctx['payment_intent_next_action_redirect_url'] = intent.next_action.redirect_to_url['url']
|
ctx['payment_intent_next_action_redirect_url'] = intent.next_action.redirect_to_url['url']
|
||||||
ctx['payment_intent_redirect_action_handling'] = prov.redirect_action_handling
|
ctx['payment_intent_redirect_action_handling'] = prov.redirect_action_handling
|
||||||
|
elif intent.next_action.type == 'swish_handle_redirect_or_display_qr_code':
|
||||||
|
ctx['payment_intent_next_action_redirect_url'] = intent.next_action.swish_handle_redirect_or_display_qr_code['hosted_instructions_url']
|
||||||
|
ctx['payment_intent_redirect_action_handling'] = 'iframe'
|
||||||
|
|
||||||
r = render(request, 'pretixplugins/stripe/sca.html', ctx)
|
r = render(request, 'pretixplugins/stripe/sca.html', ctx)
|
||||||
r._csp_ignore = True
|
r._csp_ignore = True
|
||||||
|
|||||||
Reference in New Issue
Block a user