Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove payment actions from payment details view
Marcin Gębala6638cf8a98c7
diff --git a/saleor/dashboard/payments/forms.py b/saleor/dashboard/payments/forms.pydeleted file mode 100644index 2ced7c6af5..0000000000--- a/saleor/dashboard/payments/forms.py+++ /dev/null@@ -1,5 +0,0 @@-from django import forms---class CaptureForm(forms.Form):- amount = forms.DecimalField()diff --git a/saleor/dashboard/payments/views.py b/saleor/dashboard/payments/views.pyindex 27c8053ca3..3374d5650c 100644--- a/saleor/dashboard/payments/views.py+++ b/saleor/dashboard/payments/views.py@@ -1,13 +1,8 @@-from django.contrib import messages-from django.utils.translation import ugettext_lazy as _from django.views.generic import ListView, DetailView-from django.shortcuts import redirect-from payments import PaymentErrorfrom payments.models import PAYMENT_STATUS_CHOICESfrom ..views import FilterByStatusMixinfrom ...order.models import Payment-from .forms import CaptureFormclass PaymentList(FilterByStatusMixin, ListView):@@ -28,50 +23,3 @@ class PaymentDetails(DetailView):model = Paymenttemplate_name = 'dashboard/payments/detail.html'context_object_name = 'payment'- form_class = CaptureForm-- def get_context_data(self, **kwargs):- ctx = super(PaymentDetails, self).get_context_data(**kwargs)- ctx['capture_form'] = self.get_capture_form()- ctx['refund_available'] = self.object.status == 'confirmed'- ctx['release_available'] = self.object.status == 'preauth'- return ctx-- def get_capture_form(self):- if self.object.status == 'preauth':- return self.form_class(initial={'amount': self.object.total})- else:- return None-- def post(self, *args, **kwargs):- form = self.form_class(self.request.POST)- payment = self.get_object()- error_msg = None-- if form.is_valid():- try:- payment.capture(amount=form.cleaned_data['amount'])- except PaymentError as e:- error_msg = _('Payment gateway error: ') + e.message- else:- messages.success(self.request, _('Funds captured'))-- if 'refund' in self.request.POST and payment.status == 'confirmed':- try:- payment.refund(amount=payment.captured_amount)- except PaymentError as e:- error_msg = _('Payment gateway error: ') + e.message- else:- messages.success(self.request, _('Refund successful'))-- if 'release' in self.request.POST and payment.status == 'preauth':- try:- payment.release()- except PaymentError as e:- error_msg = _('Payment gateway error: ') + e.message- else:- messages.success(self.request, _('Release successful'))-- if error_msg:- messages.error(self.request, error_msg)- return redirect('dashboard:payment-details', pk=payment.pk)diff --git a/saleor/dashboard/templates/dashboard/payments/detail.html b/saleor/dashboard/templates/dashboard/payments/detail.htmlindex 8dd0dcf969..b5e67aa52f 100644--- a/saleor/dashboard/templates/dashboard/payments/detail.html+++ b/saleor/dashboard/templates/dashboard/payments/detail.html@@ -48,37 +48,6 @@</div></div><div class="col-lg-4">- <div class="panel panel-default">- <div class="panel-heading">- <span class="payment-title">{% trans "Transaction management" %}</span>- </div>- <div class="panel-body">- {% if capture_form %}- <p>{% trans "Capture funds to continue transaction" %}</p>- <form action="." method="post">- {% csrf_token %}- {{ capture_form|as_vertical_form }}- <input type="submit" class="btn btn-success" value="Capture"/>- </form>- {% endif %}- {% if release_available %}- <p>{% trans "Release funds to abort transaction" %}</p>- <form action="." method="post">- {% csrf_token %}- <input type="hidden" name="release" value="true"/>- <input type="submit" class="btn btn-primary" value="Release"/>- </form>- {% endif %}- {% if refund_available %}- <p>{% trans "Refund funds to customer" %}</p>- <form action="." method="post">- {% csrf_token %}- <input type="hidden" name="refund" value="true"/>- <input type="submit" class="btn btn-primary" value="Refund"/>- </form>- {% endif %}- </div>- </div><div class="panel panel-default"><div class="panel-heading"><span class="panel-title">Customer account<i class="glyphicon glyphicon-user pull-right"></i></span>