Stripe: Fix test mode recognition

This commit is contained in:
Raphael Michel
2019-02-27 09:12:04 +01:00
parent 5e9e00acec
commit 8889607d1c
2 changed files with 9 additions and 2 deletions

View File

@@ -34,7 +34,14 @@ def html_head_presale(sender, request=None, **kwargs):
url = resolve(request.path_info)
if provider.settings.get('_enabled', as_type=bool) and ("checkout" in url.url_name or "order.pay" in url.url_name):
template = get_template('pretixplugins/stripe/presale_head.html')
ctx = {'event': sender, 'settings': provider.settings}
ctx = {
'event': sender,
'settings': provider.settings,
'testmode': (
(provider.settings.get('endpoint', 'live') == 'test' or sender.testmode)
and provider.settings.publishable_test_key
)
}
return template.render(ctx)
else:
return ""

View File

@@ -8,7 +8,7 @@
{% compress css %}
<link type="text/css" rel="stylesheet" href="{% static "pretixplugins/stripe/pretix-stripe.css" %}">
{% endcompress %}
{% if settings.endpoint == "test" and settings.publishable_test_key %}
{% if test_mode %}
<script type="text/plain" id="stripe_pubkey">{{ settings.publishable_test_key }}</script>
{% else %}
<script type="text/plain" id="stripe_pubkey">{{ settings.publishable_key }}</script>