Skip to content

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

Update comments and error message for is_fully_paid

Unknown5e27053911f6
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.py
index 19d587beab..7323031065 100644
--- a/saleor/checkout/utils.py
+++ b/saleor/checkout/utils.py
@@ -881,7 +881,8 @@ def create_order(cart: Cart, tracking_code: str, discounts, taxes):
def can_be_fully_paid(cart: Cart, taxes, discounts):
- """Check if checkout can be fully paid with proper payments."""
+ """Check if provided payment methods cover the checkout's total amount.
+ Note that these payments may not be captured or charged at all."""
payments = [
payment for payment in cart.payments.all() if payment.is_active]
total_paid = sum([p.total for p in payments])
@@ -907,6 +908,7 @@ def ready_to_place_order(cart: Cart, taxes, discounts):
'order placement_error', 'Billing address is not set')
if not can_be_fully_paid(cart, taxes, discounts):
return False, pgettext_lazy(
- 'order placement error',
- 'Checkout can not be fully paid with proper payments')
+ 'order placement error', (
+ 'Provided payment methods can not '
+ 'cover the checkout\'s total amount'))
return True, None
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.py
index e155ad6d5f..d5a1a69b56 100644
--- a/tests/api/test_checkout.py
+++ b/tests/api/test_checkout.py
@@ -878,8 +878,9 @@ def test_checkout_complete_no_payment(
MUTATION_CHECKOUT_COMPLETE, variables)
content = get_graphql_content(response)
data = content['data']['checkoutComplete']
- assert data['errors'][0]['message'] == \
- 'Checkout can not be fully paid with proper payments'
+ assert data['errors'][0]['message'] == (
+ 'Provided payment methods can not '
+ 'cover the checkout\'s total amount')
assert orders_count == Order.objects.count()
@@ -1163,10 +1164,12 @@ def test_ready_to_place_order_no_payment(
checkout.save()
ready, error = ready_to_place_order(checkout, None, None)
assert not ready
- assert error == 'Checkout can not be fully paid with proper payments'
+ assert error == (
+ 'Provided payment methods can not '
+ 'cover the checkout\'s total amount')
-def test_can_be_fully_paid(cart_with_item, payment_dummy):
+def test_is_fully_paid(cart_with_item, payment_dummy):
checkout = cart_with_item
total = checkout.get_total()
payment = payment_dummy