Skip to content

Commit 262f057

Browse files
authored
Upgrade stripe version (#10)
* update deprecated functions * change plugin configs * update Alipay currency * refactor: remove unused code, add blank line of end file * add Stripe signature verification * update redirect UI * refactor: improve code quality based on Sourcery-AI review * style: apply isort and flake8 fixes * refactor: Replace if statement with if expression * Add tests for Stripe webhook signature verification and error handling * update webhook test: add mock data for global settings * add data validation for payment info and update status code * add stripe setting guideline * add stripe payment methods: SEPA Direct Debit, Affirm, Klarna, PayPal and Swish * update stripe api version * update test: verify that the correct Stripe API version * update guideline image * setting guildline: fix spelling mistakes * update guideline: add setting detail for test/live mode * update guideline: add workbench note * guideline: update screenshots * docs(guideline): update signing secret for consistency * refactor: standardize nested quote styles and replace proper markdown headings * refactor: apply isort for import sorting and cleanup
1 parent 68c9208 commit 262f057

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2539
-1750
lines changed

eventyay_stripe/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.1"
22
default_app_config = 'eventyay-stripe.apps.StripePluginApp'

eventyay_stripe/apps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from django.utils.translation import gettext_lazy as _
21
from django.apps import AppConfig
2+
from django.utils.translation import gettext_lazy as _
33

44
from . import __version__
55

eventyay_stripe/payment.py

+1,641-1,282
Large diffs are not rendered by default.

eventyay_stripe/signals.py

+10-48
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,36 @@
33

44
from django import forms
55
from django.dispatch import receiver
6-
from django.http import HttpRequest
76
from django.template.loader import get_template
87
from django.urls import resolve, reverse
98
from django.utils.translation import gettext_lazy as _
10-
from paypalhttp import HttpResponse
119

1210
from pretix.base.forms import SecretKeySettingsField
13-
from pretix.base.middleware import _merge_csp, _parse_csp, _render_csp
1411
from pretix.base.settings import settings_hierarkey
1512
from pretix.base.signals import (
1613
logentry_display, register_global_settings, register_payment_providers,
1714
)
1815
from pretix.control.signals import nav_organizer
16+
from pretix.presale.signals import html_head
17+
1918
from .forms import StripeKeyValidator
20-
from .payment import StripeMethod
21-
from pretix.presale.signals import html_head, process_response
2219

2320

2421
@receiver(register_payment_providers, dispatch_uid="payment_stripe")
2522
def register_payment_provider(sender, **kwargs):
2623
from .payment import (
27-
StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS,
28-
StripeGiropay, StripeIdeal, StripeKlarna, StripeMultibanco,
29-
StripePayPal, StripePrzelewy24, StripeSEPADirectDebit,
30-
StripeSettingsHolder, StripeSofort, StripeSwish, StripeWeChatPay,
24+
StripeAffirm, StripeAlipay, StripeBancontact, StripeCreditCard,
25+
StripeEPS, StripeIdeal, StripeKlarna, StripeMobilePay,
26+
StripeMultibanco, StripePayPal, StripePrzelewy24, StripeRevolutPay,
27+
StripeSEPADirectDebit, StripeSettingsHolder, StripeSofort, StripeSwish,
28+
StripeTwint, StripeWeChatPay,
3129
)
3230

3331
return [
34-
StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact,
32+
StripeSettingsHolder, StripeCreditCard, StripeIdeal, StripeAlipay, StripeBancontact,
3533
StripeSofort, StripeEPS, StripeMultibanco, StripePrzelewy24, StripeWeChatPay,
36-
StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish
34+
StripePayPal, StripeRevolutPay, StripeSEPADirectDebit, StripeSwish, StripeTwint,
35+
StripeMobilePay, StripeAffirm, StripeKlarna
3736
]
3837

3938

@@ -163,40 +162,3 @@ def nav_o(sender, request, organizer, **kwargs):
163162
'active': 'settings.connect' in url.url_name,
164163
}]
165164
return []
166-
167-
168-
@receiver(signal=process_response, dispatch_uid="stripe_middleware_resp")
169-
def signal_process_response(sender, request: HttpRequest, response: HttpResponse, **kwargs):
170-
provider = StripeMethod(sender)
171-
url = resolve(request.path_info)
172-
173-
enabled = provider.settings.get('_enabled', as_type=bool)
174-
relevant_urls = {
175-
"event.order.pay.change",
176-
"event.order.pay",
177-
"event.checkout",
178-
"plugins:eventyay_stripe:sca",
179-
"plugins:eventyay_stripe:sca.return"
180-
}
181-
182-
if enabled and (
183-
url.url_name in relevant_urls or
184-
(url.namespace == "plugins:eventyay_stripe" and url.url_name in ["sca", "sca.return"])
185-
):
186-
if 'Content-Security-Policy' in response:
187-
csp_header = _parse_csp(response['Content-Security-Policy'])
188-
else:
189-
csp_header = {}
190-
191-
stripe_csps = {
192-
'connect-src': ['https://api.stripe.com'],
193-
'frame-src': ['https://js.stripe.com', 'https://hooks.stripe.com'],
194-
'script-src': ['https://js.stripe.com'],
195-
}
196-
197-
_merge_csp(csp_header, stripe_csps)
198-
199-
if csp_header:
200-
response['Content-Security-Policy'] = _render_csp(csp_header)
201-
202-
return response

0 commit comments

Comments
 (0)