Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Disable supporting setting partially charged for dummy gateway directly
Unknown4d5f2a748b23
diff --git a/saleor/payment/gateways/dummy/__init__.py b/saleor/payment/gateways/dummy/__init__.pyindex 168eaa4943..7b29cbdb35 100644--- a/saleor/payment/gateways/dummy/__init__.py+++ b/saleor/payment/gateways/dummy/__init__.py@@ -107,12 +107,7 @@ def process_payment(payment_information: Dict, connection_params) -> Dict:if charge_status == ChargeStatus.NOT_CHARGED:return responses- # Only capture half of the authorized amount when set to partially charged- if charge_status == ChargeStatus.PARTIALLY_CHARGED:- payment_information['amount'] = (- payment_information['amount'] / Decimal(2))responses.append(capture(payment_information, connection_params))-if charge_status == ChargeStatus.FULLY_REFUNDED:responses.append(refund(payment_information, connection_params))return responsesdiff --git a/saleor/payment/gateways/dummy/forms.py b/saleor/payment/gateways/dummy/forms.pyindex 0376d208f3..712cbcb75a 100644--- a/saleor/payment/gateways/dummy/forms.py+++ b/saleor/payment/gateways/dummy/forms.py@@ -16,11 +16,14 @@ class DummyPaymentForm(forms.Form):# Partially refunded is not supported directly# since only last transaction of call_gateway will be processedcharge_status = cleaned_data['charge_status']- if charge_status == ChargeStatus.PARTIALLY_REFUNDED:+ if charge_status in [+ ChargeStatus.PARTIALLY_CHARGED,+ ChargeStatus.PARTIALLY_REFUNDED]:raise forms.ValidationError(- _('Setting charge status to partially refunded directly '+ _('Setting charge status to {} directly ''is not supported. Please use the dashboard to '- 'refund partially.'), code='invalid_charge_status')+ 'refund partially.'.format(charge_status)),+ code='invalid_charge_status')return cleaned_datadiff --git a/tests/gateway/test_dummy.py b/tests/gateway/test_dummy.pyindex 8ab60aa7e2..1e5f2101c7 100644--- a/tests/gateway/test_dummy.py+++ b/tests/gateway/test_dummy.py@@ -245,10 +245,9 @@ def test_refund_gateway_error(payment_txn_captured, monkeypatch):'kind, charge_status',((TransactionKind.AUTH, ChargeStatus.NOT_CHARGED),- (TransactionKind.CAPTURE, ChargeStatus.PARTIALLY_CHARGED),(TransactionKind.CAPTURE, ChargeStatus.FULLY_CHARGED),(TransactionKind.REFUND, ChargeStatus.FULLY_REFUNDED), ))-def test_dummy_payment_form(kind, charge_status, settings, payment_dummy):+def test_dummy_payment_form(kind, charge_status, payment_dummy):payment = payment_dummydata = {'charge_status': charge_status}payment_gateway, gateway_params = get_payment_gateway(payment.gateway)