Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Handle no payment resolver when there is no actual payment
Tomasz Szymanski23f17583947d
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 7d8e04b815..5a15ec95c0 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -19,6 +19,7 @@ from ...graphql.utils import get_user_or_app_from_contextfrom ...order import OrderStatus, modelsfrom ...order.models import FulfillmentStatusfrom ...order.utils import get_order_country, get_valid_shipping_methods_for_order+from ...payment import ChargeStatusfrom ...product.product_images import get_product_image_thumbnailfrom ...warehouse import models as warehouse_modelsfrom ..account.dataloaders import AddressByIdLoader, UserByUserIdLoader@@ -819,8 +820,9 @@ class Order(CountableDjangoObjectType):@staticmethoddef resolve_payment_status(root: models.Order, info):def _resolve_payment_status(payments):- last_payment = max(payments, default=None, key=attrgetter("pk"))- return last_payment.charge_status+ if last_payment := max(payments, default=None, key=attrgetter("pk")):+ return last_payment.charge_status+ return ChargeStatus.NOT_CHARGEDreturn (PaymentsByOrderIdLoader(info.context)@@ -831,8 +833,9 @@ class Order(CountableDjangoObjectType):@staticmethoddef resolve_payment_status_display(root: models.Order, info):def _resolve_payment_status(payments):- last_payment = max(payments, default=None, key=attrgetter("pk"))- return last_payment.get_charge_status_display()+ if last_payment := max(payments, default=None, key=attrgetter("pk")):+ return last_payment.get_charge_status_display()+ return dict(ChargeStatus.CHOICES).get(ChargeStatus.NOT_CHARGED)return (PaymentsByOrderIdLoader(info.context)