forked from CGM_Public/pretix_original
Basic confirmation page
This commit is contained in:
@@ -8,6 +8,7 @@ from django.db.models import Q
|
||||
from django.utils.timezone import now
|
||||
|
||||
from pretix.base.models import CartPosition
|
||||
from pretix.base.signals import register_payment_providers
|
||||
|
||||
|
||||
class EventLoginRequiredMixin:
|
||||
@@ -59,10 +60,21 @@ class CartDisplayMixin:
|
||||
group.total = group.count * group.price
|
||||
positions.append(group)
|
||||
|
||||
total = sum(p.total for p in positions)
|
||||
|
||||
payment_fee = 0
|
||||
if 'payment' in self.request.session:
|
||||
responses = register_payment_providers.send(self.request.event)
|
||||
for receiver, response in responses:
|
||||
provider = response(self.request.event)
|
||||
if provider.identifier == self.request.session['payment']:
|
||||
payment_fee = provider.calculate_fee(total)
|
||||
|
||||
return {
|
||||
'positions': positions,
|
||||
'raw': cartpos,
|
||||
'total': sum(p.total for p in positions),
|
||||
'total': total + payment_fee,
|
||||
'payment_fee': payment_fee,
|
||||
'minutes_left': (
|
||||
max(min(p.expires for p in positions) - now(), timedelta()).seconds // 60
|
||||
if positions else 0
|
||||
|
||||
@@ -76,7 +76,7 @@ class QuestionsForm(forms.Form):
|
||||
self.fields['question_%s' % q.identity] = field
|
||||
|
||||
|
||||
class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
class CheckoutStart(EventViewMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_questions.html"
|
||||
|
||||
def get_success_url(self):
|
||||
@@ -183,11 +183,11 @@ class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, T
|
||||
return ctx
|
||||
|
||||
|
||||
class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
class PaymentDetails(EventViewMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_payment.html"
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('presale:event.index', kwargs={
|
||||
return reverse('presale:event.checkout.confirm', kwargs={
|
||||
'event': self.request.event.slug,
|
||||
'organizer': self.request.event.organizer.slug,
|
||||
})
|
||||
@@ -229,6 +229,7 @@ class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
def post(self, request, *args, **kwargs):
|
||||
for p in self.provider_forms:
|
||||
if p['provider'].identifier == request.POST.get('payment', ''):
|
||||
request.session['payment'] = p['provider'].identifier
|
||||
total = self._total_order_value + p['provider'].calculate_fee(self._total_order_value)
|
||||
resp = p['provider'].checkout_prepare(request, total)
|
||||
if isinstance(resp, HttpResponse):
|
||||
@@ -242,3 +243,12 @@ class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['providers'] = self.provider_forms
|
||||
return ctx
|
||||
|
||||
|
||||
class OrderConfirm(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_confirm.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['cart'] = self.get_cart()
|
||||
return ctx
|
||||
|
||||
Reference in New Issue
Block a user