Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add external service event to OrderEvent
Maciej Korycinski1cca40939fac
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex d3163fbe16..3d199c1efd 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3063,7 +3063,7 @@ enum OrderEventsEnum {EMAIL_SENTPAYMENT_AUTHORIZEDPAYMENT_CAPTURED- PAYMENT_GATEWAY_NOTIFICATION+ EXTERNAL_SERVICE_NOTIFICATIONPAYMENT_REFUNDEDPAYMENT_VOIDEDPAYMENT_FAILEDdiff --git a/saleor/order/__init__.py b/saleor/order/__init__.pyindex 0f4f05d496..89ba7e21c3 100644--- a/saleor/order/__init__.py+++ b/saleor/order/__init__.py@@ -51,7 +51,7 @@ class OrderEvents:PAYMENT_REFUNDED = "payment_refunded"PAYMENT_VOIDED = "payment_voided"PAYMENT_FAILED = "payment_failed"- PAYMENT_GATEWAY_NOTIFICATION = "payment_gateway_notification"+ EXTERNAL_SERVICE_NOTIFICATION = "external_service_notification"INVOICE_REQUESTED = "invoice_requested"INVOICE_GENERATED = "invoice_generated"@@ -81,7 +81,7 @@ class OrderEvents:(EMAIL_SENT, "The email was sent"),(PAYMENT_AUTHORIZED, "The payment was authorized"),(PAYMENT_CAPTURED, "The payment was captured"),- (PAYMENT_GATEWAY_NOTIFICATION, "Notification from payment gateway"),+ (EXTERNAL_SERVICE_NOTIFICATION, "Notification from external service"),(PAYMENT_REFUNDED, "The payment was refunded"),(PAYMENT_VOIDED, "The payment was voided"),(PAYMENT_FAILED, "The payment was failed"),diff --git a/saleor/order/events.py b/saleor/order/events.pyindex 9e24af6834..fc0b6e3dc1 100644--- a/saleor/order/events.py+++ b/saleor/order/events.py@@ -260,7 +260,7 @@ def payment_failed_event()-def payment_gateway_notification_event(+def external_notification_event(*, order: Order, user: UserType, message: str, payment: Payment) -> OrderEvent:if not _user_is_valid(user):@@ -268,11 +268,11 @@ def payment_gateway_notification_event(parameters = {"message": message}if payment:- parameters.update({"plugin": payment.gateway, "payment_id": payment.token})+ parameters.update({"service": payment.gateway, "id": payment.token})return OrderEvent.objects.create(order=order,- type=OrderEvents.PAYMENT_GATEWAY_NOTIFICATION,+ type=OrderEvents.EXTERNAL_SERVICE_NOTIFICATION,user=user,parameters=parameters,)diff --git a/saleor/payment/gateways/adyen/webhooks.py b/saleor/payment/gateways/adyen/webhooks.pyindex caa90f8dc8..bf072165f9 100644--- a/saleor/payment/gateways/adyen/webhooks.py+++ b/saleor/payment/gateways/adyen/webhooks.py@@ -18,7 +18,7 @@ from ....order.actions import (order_captured,order_refunded,)-from ....order.events import payment_gateway_notification_event+from ....order.events import external_notification_eventfrom ....payment.models import Payment, Transactionfrom ... import ChargeStatus, TransactionKindfrom ...interface import GatewayConfig, GatewayResponse@@ -74,7 +74,7 @@ def create_payment_notification_for_order(returnmsg = success_msg if is_success else failed_msg- payment_gateway_notification_event(+ external_notification_event(order=payment.order, user=None, message=msg, payment=payment)