Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Wrap notify webhook with json.dumps
Maciej Korycinski6ec0c22ac02a
diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.pyindex 290910f736..c3692df1fc 100644--- a/saleor/plugins/webhook/plugin.py+++ b/saleor/plugins/webhook/plugin.py@@ -1,5 +1,7 @@+import jsonfrom typing import TYPE_CHECKING, Any, Optional+from ...core.utils.json_serializer import CustomJsonEncoderfrom ...webhook.event_types import WebhookEventTypefrom ...webhook.payloads import (generate_checkout_payload,@@ -151,4 +153,6 @@ class WebhookPlugin(BasePlugin):if not self.active:return previous_valuedata = {"notify_event": event, "payload": payload}- trigger_webhooks_for_event.delay(WebhookEventType.NOTIFY_USER, data)+ trigger_webhooks_for_event.delay(+ WebhookEventType.NOTIFY_USER, json.dumps(data, cls=CustomJsonEncoder)+ )diff --git a/saleor/plugins/webhook/tests/test_webhook.py b/saleor/plugins/webhook/tests/test_webhook.pyindex 2e57c71938..e91fb569f2 100644--- a/saleor/plugins/webhook/tests/test_webhook.py+++ b/saleor/plugins/webhook/tests/test_webhook.py@@ -1,3 +1,4 @@+import jsonfrom unittest import mockfrom urllib.parse import urlencode@@ -12,6 +13,7 @@ from ....account.notifications import (from ....app.models import Appfrom ....core.notifications import get_site_contextfrom ....core.notify_events import NotifyEventType+from ....core.utils.json_serializer import CustomJsonEncoderfrom ....core.utils.url import prepare_urlfrom ....webhook.event_types import WebhookEventTypefrom ....webhook.payloads import (@@ -281,5 +283,5 @@ def test_notify_user(mocked_webhook_trigger, settings, customer_user):"payload": payload,}mocked_webhook_trigger.assert_called_once_with(- WebhookEventType.NOTIFY_USER, expected_data+ WebhookEventType.NOTIFY_USER, json.dumps(expected_data, cls=CustomJsonEncoder))