Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Automatically create auth transactions for dummy payments
Artur Smęt1f3e166af978
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 3b282f05c5..a5c9fc164f 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -264,7 +264,7 @@ class ManagePaymentForm(forms.Form):super().__init__(*args, **kwargs)def clean(self):- if self.payment.status != self.clean_status:+ if self.payment.charge_status != self.clean_status:raise forms.ValidationError(self.clean_error)def payment_error(self, message):diff --git a/saleor/order/views.py b/saleor/order/views.pyindex 827ae18e61..5552f7b3da 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -116,6 +116,7 @@ def start_payment(request, order, variant):form.method = "POST"if form.is_valid():form.save()+ form.authorize_payment()return redirect(order.get_absolute_url())template = 'order/payment/%s.html' % variantctx = {'form': form, 'payment': payment_method}diff --git a/saleor/payment/__init__.py b/saleor/payment/__init__.pyindex 94483307cd..a4515487ab 100644--- a/saleor/payment/__init__.py+++ b/saleor/payment/__init__.py@@ -40,7 +40,7 @@ PROVIDERS_ENUM = Enum(def get_provider(provider_name):if provider_name not in settings.PAYMENT_PROVIDERS:raise ImproperlyConfigured(- f'Payment provider {provider_name} is not configured.')+ 'Payment provider %s is not configured.' % provider_name)provider_module = importlib.import_module(settings.PAYMENT_PROVIDERS[provider_name]['module'])provider_params = settings.PAYMENT_PROVIDERS[provider_name]['connection_params']diff --git a/saleor/payment/forms.py b/saleor/payment/forms.pyindex 9b28e54090..5743117ac8 100644--- a/saleor/payment/forms.py+++ b/saleor/payment/forms.py@@ -1,8 +1,15 @@from django import formsfrom .models import PaymentMethod-+from ..payment import TransactionTypeclass PaymentMethodForm(forms.ModelForm):class Meta:model = PaymentMethodfields = ['variant', 'is_active', 'total', 'charge_status']++ def authorize_payment(self):+ self.instance.transactions.create(+ amount=self.instance.total,+ transaction_type=TransactionType.AUTH,+ gateway_response={},+ is_success=True)