Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Do not show payment if order is partly paid

jxltombf8ca4e3ad10
diff --git a/saleor/order/models.py b/saleor/order/models.py
index b5c00114fa..afaddc58ff 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -137,15 +137,23 @@ class Order(models.Model):
return super().save(*args, **kwargs)
def is_fully_paid(self):
+ total_paid = self._total_paid()
+ return total_paid.gross >= self.total.gross
+
+ def is_partly_paid(self):
+ total_paid = self._total_paid()
+ return total_paid.gross.amount > 0
+
+ def get_user_current_email(self):
+ return self.user.email if self.user else self.user_email
+
+ def _total_paid(self):
payments = self.payments.filter(
charge_status=ChargeStatus.CHARGED)
total_captured = [
payment.get_captured_amount() for payment in payments]
total_paid = sum(total_captured, ZERO_TAXED_MONEY)
- return total_paid.gross >= self.total.gross
-
- def get_user_current_email(self):
- return self.user.email if self.user else self.user_email
+ return total_paid
def _index_billing_phone(self):
return self.billing_address.phone
diff --git a/templates/order/details.html b/templates/order/details.html
index c855c77b47..52235f5347 100644
--- a/templates/order/details.html
+++ b/templates/order/details.html
@@ -50,7 +50,7 @@
Order {{ order }}: {{ order_status }}
{% endblocktrans %}
</h2>
- {% if not order.is_fully_paid %}
+ {% if not order.is_partly_paid %}
{% if order.is_pre_authorized %}
<a href="{% url "order:payment" token=order.token %}" class="btn btn-link">
{% trans "Payment details" context "Order details link text" %}