diff --git a/src/pretix/helpers/urls.py b/src/pretix/helpers/urls.py index ec9087f452..79262df390 100644 --- a/src/pretix/helpers/urls.py +++ b/src/pretix/helpers/urls.py @@ -1,5 +1,9 @@ +from urllib.parse import urljoin from django.conf import settings +from django.core.urlresolvers import reverse -def build_absolute_uri(url): - return settings.SITE_URL + url +def build_absolute_uri(urlname, args=None, kwargs=None): + # Pass prefix='' as a possible SCRIPT_PREFIX (if pretix runs in a subdirectory) + # is included in SITE_URL _and_ is added by reverse. + return urljoin(settings.SITE_URL, reverse(urlname, args, kwargs, prefix='')) diff --git a/src/pretix/plugins/paypal/payment.py b/src/pretix/plugins/paypal/payment.py index 0939f79dc5..22c4b9b9f7 100644 --- a/src/pretix/plugins/paypal/payment.py +++ b/src/pretix/plugins/paypal/payment.py @@ -89,8 +89,8 @@ class Paypal(BasePaymentProvider): "payment_method": "paypal", }, "redirect_urls": { - "return_url": build_absolute_uri(reverse('plugins:paypal:return')), - "cancel_url": build_absolute_uri(reverse('plugins:paypal:abort')), + "return_url": build_absolute_uri('plugins:paypal:return'), + "cancel_url": build_absolute_uri('plugins:paypal:abort'), }, "transactions": [ { diff --git a/src/pretix/plugins/paypal/views.py b/src/pretix/plugins/paypal/views.py index ab9695e3c7..273987b837 100644 --- a/src/pretix/plugins/paypal/views.py +++ b/src/pretix/plugins/paypal/views.py @@ -71,12 +71,12 @@ def retry(request, order): "payment_method": "paypal", }, "redirect_urls": { - "return_url": build_absolute_uri(reverse('plugins:paypal:retry', kwargs={ + "return_url": build_absolute_uri('plugins:paypal:retry', kwargs={ 'order': order.code - })), - "cancel_url": build_absolute_uri(reverse('plugins:paypal:retry', kwargs={ + }), + "cancel_url": build_absolute_uri('plugins:paypal:retry', kwargs={ 'order': order.code - })), + }), }, "transactions": [ { diff --git a/src/pretix/plugins/stripe/payment.py b/src/pretix/plugins/stripe/payment.py index f185fa9c85..73de287deb 100644 --- a/src/pretix/plugins/stripe/payment.py +++ b/src/pretix/plugins/stripe/payment.py @@ -40,7 +40,7 @@ class Stripe(BasePaymentProvider): return "
%s