Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Refactor VoidPaymentForm by subclassing ManagePaymentForm
Unknown59098fabc759
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 1130312feb..97b96b57b8 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -309,24 +309,17 @@ class RefundPaymentForm(ManagePaymentForm):return self.try_payment_action(gateway_refund)-class VoidPaymentForm(forms.Form):+class VoidPaymentForm(ManagePaymentForm):++ clean_status = ChargeStatus.NOT_CHARGED+ clean_error = pgettext_lazy('Payment form error',+ 'Only pre-authorized payments can be voided')def __init__(self, *args, **kwargs):self.payment = kwargs.pop('payment')+ self.fields.pop('amount')super().__init__(*args, **kwargs)- def clean(self):- if self.payment.charge_status != ChargeStatus.NOT_CHARGED:- raise forms.ValidationError(- pgettext_lazy(- 'Payment form error',- 'Only pre-authorized payments can be voided'))-- def payment_error(self, message):- self.add_error(- None, pgettext_lazy(- 'Payment form error', 'Payment gateway error: %s') % message)-def void(self):try:gateway_void(self.payment)