Small changes to the payment API

This commit is contained in:
Raphael Michel
2015-03-15 16:25:54 +01:00
parent 4699c74810
commit 6a2a6fdcee
2 changed files with 5 additions and 7 deletions

View File

@@ -105,7 +105,7 @@ class BasePaymentProvider:
""" """
raise NotImplementedError() # NOQA raise NotImplementedError() # NOQA
def checkout_prepare(self, request, total) -> "bool|HttpResponse": def checkout_prepare(self, request, cart) -> "bool|HttpResponse":
""" """
Will be called if the user selects this provider as his payment method. Will be called if the user selects this provider as his payment method.
If the payment provider provides a form to the user to enter payment data, If the payment provider provides a form to the user to enter payment data,
@@ -117,8 +117,6 @@ class BasePaymentProvider:
On errors, it should use Django's message framework to display an error message On errors, it should use Django's message framework to display an error message
to the user (or the normal form validation error messages). to the user (or the normal form validation error messages).
:param total: The total price of the order, including the payment method fee.
""" """
form = self.checkout_form(request) form = self.checkout_form(request)
if form.is_valid(): if form.is_valid():

View File

@@ -205,7 +205,7 @@ class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
return ctx return ctx
class PaymentDetails(EventViewMixin, EventLoginRequiredMixin, CheckoutView): class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, CheckoutView):
template_name = "pretixpresale/event/checkout_payment.html" template_name = "pretixpresale/event/checkout_payment.html"
@cached_property @cached_property
@@ -234,10 +234,10 @@ class PaymentDetails(EventViewMixin, EventLoginRequiredMixin, CheckoutView):
for p in self.provider_forms: for p in self.provider_forms:
if p['provider'].identifier == request.POST.get('payment', ''): if p['provider'].identifier == request.POST.get('payment', ''):
request.session['payment'] = p['provider'].identifier request.session['payment'] = p['provider'].identifier
total = self._total_order_value + p['provider'].calculate_fee(self._total_order_value) resp = p['provider'].checkout_prepare(
resp = p['provider'].checkout_prepare(request, total) request, self.get_cart(payment_fee=p['provider'].calculate_fee(self._total_order_value)))
if isinstance(resp, str): if isinstance(resp, str):
return redirect(str) return redirect(resp)
elif resp is True: elif resp is True:
return redirect(self.get_confirm_url()) return redirect(self.get_confirm_url())
else: else: