Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
[SALEOR-4715] Add webhook events for metadata updates (#10520)
Rafał Pitońb5c54d997eed
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ca548782df..3bb2f65052 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -36,6 +36,22 @@ All notable, unreleased changes to this project will be documented in this file.### GraphQL API- Add `taxExemptionManage` mutation - #10344 by @SzymJ+### Other changes++- Add new asynchronous events for objects metadata updates - #10520 by @rafalp+ - `CHECKOUT_METADATA_UPDATED`+ - `COLLECTION_METADATA_UPDATED`+ - `CUSTOMER_METADATA_UPDATED`+ - `FULFILLMENT_METADATA_UPDATED`+ - `GIFT_CARD_METADATA_UPDATED`+ - `ORDER_METADATA_UPDATED`+ - `PRODUCT_METADATA_UPDATED`+ - `PRODUCT_VARIANT_METADATA_UPDATED`+ - `SHIPPING_ZONE_METADATA_UPDATED`+ - `TRANSACTION_ITEM_METADATA_UPDATED`+ - `WAREHOUSE_METADATA_UPDATED`+ - `VOUCHER_METADATA_UPDATED`+# 3.7.0diff --git a/saleor/graphql/meta/extra_methods.py b/saleor/graphql/meta/extra_methods.pyindex 44f4f8ecde..3f928c7499 100644--- a/saleor/graphql/meta/extra_methods.py+++ b/saleor/graphql/meta/extra_methods.py@@ -5,28 +5,80 @@ from ..plugins.dataloaders import load_plugin_managerdef extra_checkout_actions(instance, info, **data):manager = load_plugin_manager(info.context)manager.checkout_updated(instance)+ manager.checkout_metadata_updated(instance)+++def extra_collection_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.collection_metadata_updated(instance)+++def extra_fulfillment_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.fulfillment_metadata_updated(instance)+++def extra_gift_card_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.gift_card_metadata_updated(instance)+++def extra_order_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.order_metadata_updated(instance)def extra_product_actions(instance, info, **data):manager = load_plugin_manager(info.context)manager.product_updated(instance)+ manager.product_metadata_updated(instance)def extra_variant_actions(instance, info, **data):manager = load_plugin_manager(info.context)manager.product_variant_updated(instance)+ manager.product_variant_metadata_updated(instance)+++def extra_shipping_zone_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.shipping_zone_metadata_updated(instance)+++def extra_transaction_item_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.transaction_item_metadata_updated(instance)def extra_user_actions(instance, info, **data):manager = load_plugin_manager(info.context)manager.customer_updated(instance)+ manager.customer_metadata_updated(instance)+++def extra_warehouse_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.warehouse_metadata_updated(instance)+++def extra_voucher_actions(instance, info, **data):+ manager = load_plugin_manager(info.context)+ manager.voucher_metadata_updated(instance)MODEL_EXTRA_METHODS = {"Checkout": extra_checkout_actions,+ "Collection": extra_collection_actions,+ "Fulfillment": extra_fulfillment_actions,+ "GiftCard": extra_gift_card_actions,+ "Order": extra_order_actions,"Product": extra_product_actions,"ProductVariant": extra_variant_actions,+ "ShippingZone": extra_shipping_zone_actions,+ "TransactionItem": extra_transaction_item_actions,"User": extra_user_actions,+ "Warehouse": extra_warehouse_actions,+ "Voucher": extra_voucher_actions,}diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 611c7ce352..25f41b63bc 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -1422,6 +1422,15 @@ enum WebhookEventTypeEnum {"""A gift card status is changed."""GIFT_CARD_STATUS_CHANGED+ """+ A gift card metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ GIFT_CARD_METADATA_UPDATED+"""A new menu created."""MENU_CREATED@@ -1462,6 +1471,15 @@ enum WebhookEventTypeEnum {"""An order is fulfilled."""ORDER_FULFILLED+ """+ An order metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ ORDER_METADATA_UPDATED+"""A draft order is created."""DRAFT_ORDER_CREATED@@ -1501,6 +1519,15 @@ enum WebhookEventTypeEnum {"""A customer account is deleted."""CUSTOMER_DELETED+ """+ A customer account metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ CUSTOMER_METADATA_UPDATED+"""A new collection is created."""COLLECTION_CREATED@@ -1510,6 +1537,15 @@ enum WebhookEventTypeEnum {"""A collection is deleted."""COLLECTION_DELETED+ """+ A collection metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ COLLECTION_METADATA_UPDATED+"""A new product is created."""PRODUCT_CREATED@@ -1519,6 +1555,15 @@ enum WebhookEventTypeEnum {"""A product is deleted."""PRODUCT_DELETED+ """+ A product metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ PRODUCT_METADATA_UPDATED+"""A new product variant is created."""PRODUCT_VARIANT_CREATED@@ -1534,6 +1579,15 @@ enum WebhookEventTypeEnum {"""A product variant is back in stock."""PRODUCT_VARIANT_BACK_IN_STOCK+ """+ A product variant metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ PRODUCT_VARIANT_METADATA_UPDATED+"""A new checkout is created."""CHECKOUT_CREATED@@ -1542,6 +1596,15 @@ enum WebhookEventTypeEnum {"""CHECKOUT_UPDATED+ """+ A checkout metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ CHECKOUT_METADATA_UPDATED+"""A new fulfillment is created."""FULFILLMENT_CREATED@@ -1551,6 +1614,15 @@ enum WebhookEventTypeEnum {"""A fulfillment is approved."""FULFILLMENT_APPROVED+ """+ A fulfillment metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ FULFILLMENT_METADATA_UPDATED+"""User notification triggered."""NOTIFY_USER@@ -1599,6 +1671,15 @@ enum WebhookEventTypeEnum {"""A shipping zone is deleted."""SHIPPING_ZONE_DELETED+ """+ A shipping zone metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ SHIPPING_ZONE_METADATA_UPDATED+"""A new staff user is created."""STAFF_CREATED@@ -1611,6 +1692,15 @@ enum WebhookEventTypeEnum {"""An action requested for transaction."""TRANSACTION_ACTION_REQUEST+ """+ Transaction item metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ TRANSACTION_ITEM_METADATA_UPDATED+"""A new translation is created."""TRANSLATION_CREATED@@ -1626,6 +1716,15 @@ enum WebhookEventTypeEnum {"""A warehouse is deleted."""WAREHOUSE_DELETED+ """+ A warehouse metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ WAREHOUSE_METADATA_UPDATED+"""A new voucher created."""VOUCHER_CREATED@@ -1635,6 +1734,15 @@ enum WebhookEventTypeEnum {"""A voucher is deleted."""VOUCHER_DELETED+ """+ A voucher metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ VOUCHER_METADATA_UPDATED+"""An observability event is created."""OBSERVABILITY@@ -1833,6 +1941,15 @@ enum WebhookEventTypeAsyncEnum {"""A gift card status is changed."""GIFT_CARD_STATUS_CHANGED+ """+ A gift card metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ GIFT_CARD_METADATA_UPDATED+"""A new menu created."""MENU_CREATED@@ -1873,6 +1990,15 @@ enum WebhookEventTypeAsyncEnum {"""An order is fulfilled."""ORDER_FULFILLED+ """+ An order metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ ORDER_METADATA_UPDATED+"""A draft order is created."""DRAFT_ORDER_CREATED@@ -1912,6 +2038,15 @@ enum WebhookEventTypeAsyncEnum {"""A customer account is deleted."""CUSTOMER_DELETED+ """+ A customer account metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ CUSTOMER_METADATA_UPDATED+"""A new collection is created."""COLLECTION_CREATED@@ -1921,6 +2056,15 @@ enum WebhookEventTypeAsyncEnum {"""A collection is deleted."""COLLECTION_DELETED+ """+ A collection metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ COLLECTION_METADATA_UPDATED+"""A new product is created."""PRODUCT_CREATED@@ -1930,6 +2074,15 @@ enum WebhookEventTypeAsyncEnum {"""A product is deleted."""PRODUCT_DELETED+ """+ A product metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ PRODUCT_METADATA_UPDATED+"""A new product variant is created."""PRODUCT_VARIANT_CREATED@@ -1945,6 +2098,15 @@ enum WebhookEventTypeAsyncEnum {"""A product variant is back in stock."""PRODUCT_VARIANT_BACK_IN_STOCK+ """+ A product variant metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ PRODUCT_VARIANT_METADATA_UPDATED+"""A new checkout is created."""CHECKOUT_CREATED@@ -1953,6 +2115,15 @@ enum WebhookEventTypeAsyncEnum {"""CHECKOUT_UPDATED+ """+ A checkout metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ CHECKOUT_METADATA_UPDATED+"""A new fulfillment is created."""FULFILLMENT_CREATED@@ -1962,6 +2133,15 @@ enum WebhookEventTypeAsyncEnum {"""A fulfillment is approved."""FULFILLMENT_APPROVED+ """+ A fulfillment metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ FULFILLMENT_METADATA_UPDATED+"""User notification triggered."""NOTIFY_USER@@ -2010,6 +2190,15 @@ enum WebhookEventTypeAsyncEnum {"""A shipping zone is deleted."""SHIPPING_ZONE_DELETED+ """+ A shipping zone metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ SHIPPING_ZONE_METADATA_UPDATED+"""A new staff user is created."""STAFF_CREATED@@ -2022,6 +2211,15 @@ enum WebhookEventTypeAsyncEnum {"""An action requested for transaction."""TRANSACTION_ACTION_REQUEST+ """+ Transaction item metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ TRANSACTION_ITEM_METADATA_UPDATED+"""A new translation is created."""TRANSLATION_CREATED@@ -2037,6 +2235,15 @@ enum WebhookEventTypeAsyncEnum {"""A warehouse is deleted."""WAREHOUSE_DELETED+ """+ A warehouse metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ WAREHOUSE_METADATA_UPDATED+"""A new voucher created."""VOUCHER_CREATED@@ -2046,6 +2253,15 @@ enum WebhookEventTypeAsyncEnum {"""A voucher is deleted."""VOUCHER_DELETED+ """+ A voucher metadata is updated.++ Added in Saleor 3.8.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ VOUCHER_METADATA_UPDATED+"""An observability event is created."""OBSERVABILITY}@@ -2549,6 +2765,7 @@ enum WebhookSampleEventTypeEnum {GIFT_CARD_UPDATEDGIFT_CARD_DELETEDGIFT_CARD_STATUS_CHANGED+ GIFT_CARD_METADATA_UPDATEDMENU_CREATEDMENU_UPDATEDMENU_DELETED@@ -2561,6 +2778,7 @@ enum WebhookSampleEventTypeEnum {ORDER_UPDATEDORDER_CANCELLEDORDER_FULFILLED+ ORDER_METADATA_UPDATEDDRAFT_ORDER_CREATEDDRAFT_ORDER_UPDATEDDRAFT_ORDER_DELETED@@ -2574,22 +2792,28 @@ enum WebhookSampleEventTypeEnum {CUSTOMER_CREATEDCUSTOMER_UPDATEDCUSTOMER_DELETED+ CUSTOMER_METADATA_UPDATEDCOLLECTION_CREATEDCOLLECTION_UPDATEDCOLLECTION_DELETED+ COLLECTION_METADATA_UPDATEDPRODUCT_CREATEDPRODUCT_UPDATEDPRODUCT_DELETED+ PRODUCT_METADATA_UPDATEDPRODUCT_VARIANT_CREATEDPRODUCT_VARIANT_UPDATEDPRODUCT_VARIANT_DELETEDPRODUCT_VARIANT_OUT_OF_STOCKPRODUCT_VARIANT_BACK_IN_STOCK+ PRODUCT_VARIANT_METADATA_UPDATEDCHECKOUT_CREATEDCHECKOUT_UPDATED+ CHECKOUT_METADATA_UPDATEDFULFILLMENT_CREATEDFULFILLMENT_CANCELEDFULFILLMENT_APPROVED+ FULFILLMENT_METADATA_UPDATEDNOTIFY_USERPAGE_CREATEDPAGE_UPDATED@@ -2606,18 +2830,22 @@ enum WebhookSampleEventTypeEnum {SHIPPING_ZONE_CREATEDSHIPPING_ZONE_UPDATEDSHIPPING_ZONE_DELETED+ SHIPPING_ZONE_METADATA_UPDATEDSTAFF_CREATEDSTAFF_UPDATEDSTAFF_DELETEDTRANSACTION_ACTION_REQUEST+ TRANSACTION_ITEM_METADATA_UPDATEDTRANSLATION_CREATEDTRANSLATION_UPDATEDWAREHOUSE_CREATEDWAREHOUSE_UPDATEDWAREHOUSE_DELETED+ WAREHOUSE_METADATA_UPDATEDVOUCHER_CREATEDVOUCHER_UPDATEDVOUCHER_DELETED+ VOUCHER_METADATA_UPDATEDOBSERVABILITY}@@ -22475,6 +22703,30 @@ type GiftCardStatusChanged implements Event {giftCard: GiftCard}+"""+Event sent when gift card metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type GiftCardMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The gift card the event relates to."""+ giftCard: GiftCard+}+"""Event sent when new menu is created.@@ -22781,6 +23033,30 @@ type OrderCancelled implements Event {order: Order}+"""+Event sent when order metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type OrderMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The order the event relates to."""+ order: Order+}+"""Event sent when new draft order is created.@@ -22943,6 +23219,36 @@ type ProductDeleted implements Event {category: Category}+"""+Event sent when product metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type ProductMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The product the event relates to."""+ product(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): Product++ """The category of the product."""+ category: Category+}+"""Event sent when new product variant is created.@@ -23084,6 +23390,33 @@ type ProductVariantDeleted implements Event {): ProductVariant}+"""+Event sent when product variant metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type ProductVariantMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The product variant the event relates to."""+ productVariant(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): ProductVariant+}+"""Event sent when new sale is created.@@ -23351,6 +23684,33 @@ type FulfillmentApproved implements Event {order: Order}+"""+Event sent when fulfillment metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type FulfillmentMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The fulfillment the event relates to."""+ fulfillment: Fulfillment++ """The order the fulfillment belongs to."""+ order: Order+}+"""Event sent when new customer user is created.@@ -23399,6 +23759,30 @@ type CustomerUpdated implements Event {user: User}+"""+Event sent when customer user metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type CustomerMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The user the event relates to."""+ user: User+}+"""Event sent when new collection is created.@@ -23480,6 +23864,33 @@ type CollectionDeleted implements Event {): Collection}+"""+Event sent when collection metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type CollectionMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The collection the event relates to."""+ collection(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): Collection+}+"""Event sent when new checkout is created.@@ -23528,6 +23939,30 @@ type CheckoutUpdated implements Event {checkout: Checkout}+"""+Event sent when checkout metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type CheckoutMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The checkout the event relates to."""+ checkout: Checkout+}+"""Event sent when new page is created.@@ -23924,6 +24359,33 @@ type ShippingZoneDeleted implements Event {): ShippingZone}+"""+Event sent when shipping zone metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type ShippingZoneMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The shipping zone the event relates to."""+ shippingZone(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): ShippingZone+}+"""Event sent when new staff user is created.@@ -24043,6 +24505,34 @@ type TransactionAction {amount: PositiveDecimal}+"""+Event sent when transaction item metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type TransactionItemMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """+ Look up a transaction.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ transaction: TransactionItem+}+"""Event sent when new translation is created.@@ -24174,6 +24664,33 @@ type VoucherDeleted implements Event {): Voucher}+"""+Event sent when voucher metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type VoucherMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The voucher the event relates to."""+ voucher(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): Voucher+}+"""Event sent when new warehouse is created.@@ -24246,6 +24763,30 @@ type WarehouseDeleted implements Event {warehouse: Warehouse}+"""+Event sent when warehouse metadata is updated.++Added in Saleor 3.8.++Note: this API is currently in Feature Preview and can be subject to changes at later point.+"""+type WarehouseMetadataUpdated implements Event {+ """Time of the event."""+ issuedAt: DateTime++ """Saleor version that triggered the event."""+ version: String++ """The user or application that triggered the event."""+ issuingPrincipal: IssuingPrincipal++ """The application receiving the webhook."""+ recipient: App++ """The warehouse the event relates to."""+ warehouse: Warehouse+}+"""Authorize payment.diff --git a/saleor/graphql/webhook/enums.py b/saleor/graphql/webhook/enums.pyindex 1ad0244fdc..a2e3d4a923 100644--- a/saleor/graphql/webhook/enums.py+++ b/saleor/graphql/webhook/enums.py@@ -1,7 +1,7 @@import graphenefrom ...webhook.event_types import WebhookEventAsyncType, WebhookEventSyncType-from ..core.descriptions import ADDED_IN_36, PREVIEW_FEATURE+from ..core.descriptions import ADDED_IN_36, ADDED_IN_38, PREVIEW_FEATUREfrom ..core.utils import str_to_enumcheckout_updated_event_enum_description = (@@ -46,16 +46,28 @@ WEBHOOK_EVENT_DESCRIPTION = {WebhookEventAsyncType.CHANNEL_STATUS_CHANGED: "A channel status is changed.",WebhookEventAsyncType.CHECKOUT_CREATED: "A new checkout is created.",WebhookEventAsyncType.CHECKOUT_UPDATED: checkout_updated_event_enum_description,+ WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED: (+ "A checkout metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.COLLECTION_CREATED: "A new collection is created.",WebhookEventAsyncType.COLLECTION_UPDATED: "A collection is updated.",WebhookEventAsyncType.COLLECTION_DELETED: "A collection is deleted.",+ WebhookEventAsyncType.COLLECTION_METADATA_UPDATED: (+ "A collection metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.CUSTOMER_CREATED: "A new customer account is created.",WebhookEventAsyncType.CUSTOMER_UPDATED: "A customer account is updated.",WebhookEventAsyncType.CUSTOMER_DELETED: "A customer account is deleted.",+ WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED: (+ "A customer account metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.GIFT_CARD_CREATED: "A new gift card created.",WebhookEventAsyncType.GIFT_CARD_UPDATED: "A gift card is updated.",WebhookEventAsyncType.GIFT_CARD_DELETED: "A gift card is deleted.",WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED: "A gift card status is changed.",+ WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED: (+ "A gift card metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.INVOICE_REQUESTED: "An invoice for order requested.",WebhookEventAsyncType.INVOICE_DELETED: "An invoice is deleted.",WebhookEventAsyncType.INVOICE_SENT: "Invoice has been sent.",@@ -72,6 +84,9 @@ WEBHOOK_EVENT_DESCRIPTION = {WebhookEventAsyncType.ORDER_UPDATED: order_updated_event_enum_description,WebhookEventAsyncType.ORDER_CANCELLED: "An order is cancelled.",WebhookEventAsyncType.ORDER_FULFILLED: "An order is fulfilled.",+ WebhookEventAsyncType.ORDER_METADATA_UPDATED: (+ "An order metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.DRAFT_ORDER_CREATED: "A draft order is created.",WebhookEventAsyncType.DRAFT_ORDER_UPDATED: "A draft order is updated.",WebhookEventAsyncType.DRAFT_ORDER_DELETED: "A draft order is deleted.",@@ -82,6 +97,9 @@ WEBHOOK_EVENT_DESCRIPTION = {WebhookEventAsyncType.FULFILLMENT_CREATED: "A new fulfillment is created.",WebhookEventAsyncType.FULFILLMENT_CANCELED: "A fulfillment is cancelled.",WebhookEventAsyncType.FULFILLMENT_APPROVED: "A fulfillment is approved.",+ WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED: (+ "A fulfillment metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.PAGE_CREATED: "A new page is created.",WebhookEventAsyncType.PAGE_UPDATED: "A page is updated.",WebhookEventAsyncType.PAGE_DELETED: "A page is deleted.",@@ -96,9 +114,15 @@ WEBHOOK_EVENT_DESCRIPTION = {WebhookEventAsyncType.PRODUCT_CREATED: "A new product is created.",WebhookEventAsyncType.PRODUCT_UPDATED: "A product is updated.",WebhookEventAsyncType.PRODUCT_DELETED: "A product is deleted.",+ WebhookEventAsyncType.PRODUCT_METADATA_UPDATED: (+ "A product metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.PRODUCT_VARIANT_CREATED: "A new product variant is created.",WebhookEventAsyncType.PRODUCT_VARIANT_UPDATED: "A product variant is updated.",WebhookEventAsyncType.PRODUCT_VARIANT_DELETED: "A product variant is deleted.",+ WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED: (+ "A product variant metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCK: ("A product variant is out of stock."),@@ -111,20 +135,32 @@ WEBHOOK_EVENT_DESCRIPTION = {WebhookEventAsyncType.SHIPPING_ZONE_CREATED: "A new shipping zone is created.",WebhookEventAsyncType.SHIPPING_ZONE_UPDATED: "A shipping zone is updated.",WebhookEventAsyncType.SHIPPING_ZONE_DELETED: "A shipping zone is deleted.",+ WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED: (+ "A shipping zone metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.STAFF_CREATED: "A new staff user is created.",WebhookEventAsyncType.STAFF_UPDATED: "A staff user is updated.",WebhookEventAsyncType.STAFF_DELETED: "A staff user is deleted.",WebhookEventAsyncType.TRANSACTION_ACTION_REQUEST: ("An action requested for transaction."),+ WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED: (+ "Transaction item metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.TRANSLATION_CREATED: "A new translation is created.",WebhookEventAsyncType.TRANSLATION_UPDATED: "A translation is updated.",WebhookEventAsyncType.WAREHOUSE_CREATED: "A new warehouse created.",WebhookEventAsyncType.WAREHOUSE_UPDATED: "A warehouse is updated.",WebhookEventAsyncType.WAREHOUSE_DELETED: "A warehouse is deleted.",+ WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED: (+ "A warehouse metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.VOUCHER_CREATED: "A new voucher created.",WebhookEventAsyncType.VOUCHER_UPDATED: "A voucher is updated.",WebhookEventAsyncType.VOUCHER_DELETED: "A voucher is deleted.",+ WebhookEventAsyncType.VOUCHER_METADATA_UPDATED: (+ "A voucher metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ ),WebhookEventAsyncType.ANY: "All the events.",WebhookEventAsyncType.OBSERVABILITY: "An observability event is created.",WebhookEventSyncType.SHIPPING_LIST_METHODS_FOR_CHECKOUT: (diff --git a/saleor/graphql/webhook/subscription_types.py b/saleor/graphql/webhook/subscription_types.pyindex 8a44011dca..3191e856f9 100644--- a/saleor/graphql/webhook/subscription_types.py+++ b/saleor/graphql/webhook/subscription_types.py@@ -30,6 +30,7 @@ from ..core.descriptions import (ADDED_IN_35,ADDED_IN_36,ADDED_IN_37,+ ADDED_IN_38,PREVIEW_FEATURE,)from ..core.scalars import PositiveDecimal@@ -403,6 +404,14 @@ class OrderCancelled(ObjectType, OrderBase):)+class OrderMetadataUpdated(ObjectType, OrderBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when order metadata is updated." + ADDED_IN_38 + PREVIEW_FEATURE+ )++class DraftOrderCreated(ObjectType, OrderBase):class Meta:interfaces = (Event,)@@ -475,6 +484,16 @@ class GiftCardStatusChanged(ObjectType, GiftCardBase):)+class GiftCardMetadataUpdated(ObjectType, GiftCardBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when gift card metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class MenuBase(AbstractType):menu = graphene.Field("saleor.graphql.menu.types.Menu",@@ -597,6 +616,16 @@ class ProductDeleted(ObjectType, ProductBase):)+class ProductMetadataUpdated(ObjectType, ProductBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when product metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class ProductVariantBase(AbstractType):product_variant = graphene.Field("saleor.graphql.product.types.ProductVariant",@@ -642,6 +671,16 @@ class ProductVariantDeleted(ObjectType, ProductVariantBase):)+class ProductVariantMetadataUpdated(ObjectType, ProductVariantBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when product variant metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class ProductVariantOutOfStock(ObjectType, ProductVariantBase):warehouse = graphene.Field("saleor.graphql.warehouse.types.Warehouse", description="Look up a warehouse."@@ -826,6 +865,16 @@ class FulfillmentApproved(ObjectType, FulfillmentBase):)+class FulfillmentMetadataUpdated(ObjectType, FulfillmentBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when fulfillment metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class UserBase(AbstractType):user = graphene.Field("saleor.graphql.account.types.User",@@ -856,6 +905,16 @@ class CustomerUpdated(ObjectType, UserBase):)+class CustomerMetadataUpdated(ObjectType, UserBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when customer user metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class CollectionBase(AbstractType):collection = graphene.Field("saleor.graphql.product.types.products.Collection",@@ -895,6 +954,16 @@ class CollectionDeleted(ObjectType, CollectionBase):)+class CollectionMetadataUpdated(ObjectType, CollectionBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when collection metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class CheckoutBase(AbstractType):checkout = graphene.Field("saleor.graphql.checkout.types.Checkout",@@ -923,6 +992,16 @@ class CheckoutUpdated(ObjectType, CheckoutBase):)+class CheckoutMetadataUpdated(ObjectType, CheckoutBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when checkout metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class PageBase(AbstractType):page = graphene.Field("saleor.graphql.page.types.Page", description="The page the event relates to."@@ -1126,6 +1205,16 @@ class ShippingZoneDeleted(ObjectType, ShippingZoneBase):)+class ShippingZoneMetadataUpdated(ObjectType, ShippingZoneBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when shipping zone metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class StaffCreated(ObjectType, UserBase):class Meta:interfaces = (Event,)@@ -1199,6 +1288,26 @@ class TransactionActionRequest(ObjectType):return transaction_action_data+class TransactionItemMetadataUpdated(ObjectType):+ transaction = graphene.Field(+ TransactionItem,+ description="Look up a transaction." + PREVIEW_FEATURE,+ )++ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when transaction item metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++ @staticmethod+ def resolve_transaction(root, _info):+ _, transaction_item = root+ return transaction_item++class TranslationTypes(Union):class Meta:types = tuple(TRANSLATIONS_TYPES_MAP.values())@@ -1280,6 +1389,16 @@ class VoucherDeleted(ObjectType, VoucherBase):)+class VoucherMetadataUpdated(ObjectType, VoucherBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when voucher metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class WarehouseBase(AbstractType):warehouse = graphene.Field("saleor.graphql.warehouse.types.Warehouse",@@ -1459,6 +1578,16 @@ class WarehouseDeleted(ObjectType, WarehouseBase):)+class WarehouseMetadataUpdated(ObjectType, WarehouseBase):+ class Meta:+ interfaces = (Event,)+ description = (+ "Event sent when warehouse metadata is updated."+ + ADDED_IN_38+ + PREVIEW_FEATURE+ )++class Subscription(ObjectType):event = graphene.Field(Event,@@ -1495,6 +1624,7 @@ WEBHOOK_TYPES_MAP = {WebhookEventAsyncType.GIFT_CARD_UPDATED: GiftCardUpdated,WebhookEventAsyncType.GIFT_CARD_DELETED: GiftCardDeleted,WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED: GiftCardStatusChanged,+ WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED: GiftCardMetadataUpdated,WebhookEventAsyncType.MENU_CREATED: MenuCreated,WebhookEventAsyncType.MENU_UPDATED: MenuUpdated,WebhookEventAsyncType.MENU_DELETED: MenuDeleted,@@ -1507,17 +1637,22 @@ WEBHOOK_TYPES_MAP = {WebhookEventAsyncType.ORDER_FULLY_PAID: OrderFullyPaid,WebhookEventAsyncType.ORDER_FULFILLED: OrderFulfilled,WebhookEventAsyncType.ORDER_CANCELLED: OrderCancelled,+ WebhookEventAsyncType.ORDER_METADATA_UPDATED: OrderMetadataUpdated,WebhookEventAsyncType.DRAFT_ORDER_CREATED: DraftOrderCreated,WebhookEventAsyncType.DRAFT_ORDER_UPDATED: DraftOrderUpdated,WebhookEventAsyncType.DRAFT_ORDER_DELETED: DraftOrderDeleted,WebhookEventAsyncType.PRODUCT_CREATED: ProductCreated,WebhookEventAsyncType.PRODUCT_UPDATED: ProductUpdated,WebhookEventAsyncType.PRODUCT_DELETED: ProductDeleted,+ WebhookEventAsyncType.PRODUCT_METADATA_UPDATED: ProductMetadataUpdated,WebhookEventAsyncType.PRODUCT_VARIANT_CREATED: ProductVariantCreated,WebhookEventAsyncType.PRODUCT_VARIANT_UPDATED: ProductVariantUpdated,- WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCK: (ProductVariantOutOfStock),- WebhookEventAsyncType.PRODUCT_VARIANT_BACK_IN_STOCK: (ProductVariantBackInStock),+ WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCK: ProductVariantOutOfStock,+ WebhookEventAsyncType.PRODUCT_VARIANT_BACK_IN_STOCK: ProductVariantBackInStock,WebhookEventAsyncType.PRODUCT_VARIANT_DELETED: ProductVariantDeleted,+ WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED: (+ ProductVariantMetadataUpdated+ ),WebhookEventAsyncType.SALE_CREATED: SaleCreated,WebhookEventAsyncType.SALE_UPDATED: SaleUpdated,WebhookEventAsyncType.SALE_DELETED: SaleDeleted,@@ -1528,13 +1663,17 @@ WEBHOOK_TYPES_MAP = {WebhookEventAsyncType.FULFILLMENT_CREATED: FulfillmentCreated,WebhookEventAsyncType.FULFILLMENT_CANCELED: FulfillmentCanceled,WebhookEventAsyncType.FULFILLMENT_APPROVED: FulfillmentApproved,+ WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED: FulfillmentMetadataUpdated,WebhookEventAsyncType.CUSTOMER_CREATED: CustomerCreated,WebhookEventAsyncType.CUSTOMER_UPDATED: CustomerUpdated,+ WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED: CustomerMetadataUpdated,WebhookEventAsyncType.COLLECTION_CREATED: CollectionCreated,WebhookEventAsyncType.COLLECTION_UPDATED: CollectionUpdated,WebhookEventAsyncType.COLLECTION_DELETED: CollectionDeleted,+ WebhookEventAsyncType.COLLECTION_METADATA_UPDATED: CollectionMetadataUpdated,WebhookEventAsyncType.CHECKOUT_CREATED: CheckoutCreated,WebhookEventAsyncType.CHECKOUT_UPDATED: CheckoutUpdated,+ WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED: CheckoutMetadataUpdated,WebhookEventAsyncType.PAGE_CREATED: PageCreated,WebhookEventAsyncType.PAGE_UPDATED: PageUpdated,WebhookEventAsyncType.PAGE_DELETED: PageDeleted,@@ -1550,18 +1689,24 @@ WEBHOOK_TYPES_MAP = {WebhookEventAsyncType.SHIPPING_ZONE_CREATED: ShippingZoneCreated,WebhookEventAsyncType.SHIPPING_ZONE_UPDATED: ShippingZoneUpdated,WebhookEventAsyncType.SHIPPING_ZONE_DELETED: ShippingZoneDeleted,+ WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED: ShippingZoneMetadataUpdated,WebhookEventAsyncType.STAFF_CREATED: StaffCreated,WebhookEventAsyncType.STAFF_UPDATED: StaffUpdated,WebhookEventAsyncType.STAFF_DELETED: StaffDeleted,WebhookEventAsyncType.TRANSACTION_ACTION_REQUEST: TransactionActionRequest,+ WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED: (+ TransactionItemMetadataUpdated+ ),WebhookEventAsyncType.TRANSLATION_CREATED: TranslationCreated,WebhookEventAsyncType.TRANSLATION_UPDATED: TranslationUpdated,WebhookEventAsyncType.VOUCHER_CREATED: VoucherCreated,WebhookEventAsyncType.VOUCHER_UPDATED: VoucherUpdated,WebhookEventAsyncType.VOUCHER_DELETED: VoucherDeleted,+ WebhookEventAsyncType.VOUCHER_METADATA_UPDATED: VoucherMetadataUpdated,WebhookEventAsyncType.WAREHOUSE_CREATED: WarehouseCreated,WebhookEventAsyncType.WAREHOUSE_UPDATED: WarehouseUpdated,WebhookEventAsyncType.WAREHOUSE_DELETED: WarehouseDeleted,+ WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED: WarehouseMetadataUpdated,WebhookEventSyncType.PAYMENT_AUTHORIZE: PaymentAuthorize,WebhookEventSyncType.PAYMENT_CAPTURE: PaymentCaptureEvent,WebhookEventSyncType.PAYMENT_REFUND: PaymentRefundEvent,diff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.pyindex e51a99dc01..7b7deb9ffc 100644--- a/saleor/plugins/base_plugin.py+++ b/saleor/plugins/base_plugin.py@@ -53,6 +53,7 @@ if TYPE_CHECKING:from ..menu.models import Menu, MenuItemfrom ..order.models import Fulfillment, Order, OrderLinefrom ..page.models import Page, PageType+ from ..payment.models import TransactionItemfrom ..product.models import (Category,Collection,@@ -405,6 +406,12 @@ class BasePlugin:# updated.checkout_updated: Callable[["Checkout", Any], Any]+ # Trigger when checkout metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic when a checkout+ # metadata is updated.+ checkout_metadata_updated: Callable[["Checkout", Any], Any]+# Trigger when collection is created.## Overwrite this method if you need to trigger specific logic after a collection is@@ -423,6 +430,12 @@ class BasePlugin:# updated.collection_updated: Callable[["Collection", Any], Any]+ # Trigger when collection metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a collection+ # metadata is updated.+ collection_metadata_updated: Callable[["Collection", Any], Any]+confirm_payment: Callable[["PaymentData", Any], GatewayResponse]# Trigger when user is created.@@ -443,6 +456,12 @@ class BasePlugin:# updated.customer_updated: Callable[["User", Any], Any]+ # Trigger when user metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a user+ # metadata is updated.+ customer_metadata_updated: Callable[["User", Any], Any]+# Handle authentication request.## Overwrite this method if the plugin handles authentication flow.@@ -479,22 +498,30 @@ class BasePlugin:# Triggered when ShopFetchTaxRates mutation is called.fetch_taxes_data: Callable[[Any], Any]- # Trigger when fulfillemnt is created.+ # Trigger when fulfillment is created.## Overwrite this method if you need to trigger specific logic when a fulfillment is# created.fulfillment_created: Callable[["Fulfillment", Any], Any]- # Trigger when fulfillemnt is cancelled.+ # Trigger when fulfillment is cancelled.+ ## Overwrite this method if you need to trigger specific logic when a fulfillment is# cancelled.fulfillment_canceled: Callable[["Fulfillment", Any], Any]- # Trigger when fulfillemnt is approved.+ # Trigger when fulfillment is approved.+ ## Overwrite this method if you need to trigger specific logic when a fulfillment is# approved.fulfillment_approved: Callable[["Fulfillment", Any], Any]+ # Trigger when fulfillment metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic when a fulfillment+ # metadata is updated.+ fulfillment_metadata_updated: Callable[["Fulfillment", Any], Any]+get_checkout_line_tax_rate: Callable[["CheckoutInfo",@@ -579,6 +606,12 @@ class BasePlugin:# updated.gift_card_updated: Callable[["GiftCard", None], None]+ # Trigger when gift card metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a gift card+ # metadata is updated.+ gift_card_metadata_updated: Callable[["GiftCard", None], None]+# Trigger when gift card status is changed.## Overwrite this method if you need to trigger specific logic after a gift card@@ -682,6 +715,12 @@ class BasePlugin:# changed.order_updated: Callable[["Order", Any], Any]+ # Trigger when order metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic when an order+ # metadata is changed.+ order_metadata_updated: Callable[["Order", Any], Any]+# Trigger when page is created.## Overwrite this method if you need to trigger specific logic when a page is@@ -754,6 +793,12 @@ class BasePlugin:transaction_action_request: Callable[["TransactionActionData", None], None]+ # Trigger when transaction item metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic when a transaction+ # item metadata is updated.+ transaction_item_metadata_updated: Callable[["TransactionItem", Any], Any]+# Trigger when product is created.## Overwrite this method if you need to trigger specific logic after a product is@@ -772,6 +817,12 @@ class BasePlugin:# updated.product_updated: Callable[["Product", Any], Any]+ # Trigger when product metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a product+ # metadata is updated.+ product_metadata_updated: Callable[["Product", Any], Any]+# Trigger when product variant is created.## Overwrite this method if you need to trigger specific logic after a product@@ -790,6 +841,12 @@ class BasePlugin:# variant is updated.product_variant_updated: Callable[["ProductVariant", Any], Any]+ # Trigger when product variant metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a product+ # variant metadata is updated.+ product_variant_metadata_updated: Callable[["ProductVariant", Any], Any]+refund_payment: Callable[["PaymentData", Any], GatewayResponse]# Trigger when sale is created.@@ -845,6 +902,12 @@ class BasePlugin:# is updated.shipping_zone_updated: Callable[["ShippingZone", None], None]+ # Trigger when shipping zone metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a shipping zone+ # metadata is updated.+ shipping_zone_metadata_updated: Callable[["ShippingZone", None], None]+# Define if storefront should add info about taxes to the price.## It is used only by the old storefront. The returned value determines if@@ -892,6 +955,12 @@ class BasePlugin:# updated.warehouse_updated: Callable[["Warehouse", None], None]+ # Trigger when warehouse metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a warehouse+ # metadata is updated.+ warehouse_metadata_updated: Callable[["Warehouse", None], None]+# Trigger when voucher is created.## Overwrite this method if you need to trigger specific logic after a voucher is@@ -910,6 +979,12 @@ class BasePlugin:# updated.voucher_updated: Callable[["Voucher", None], None]+ # Trigger when voucher metadata is updated.+ #+ # Overwrite this method if you need to trigger specific logic after a voucher+ # metadata is updated.+ voucher_metadata_updated: Callable[["Voucher", None], None]+# Handle received http request.## Overwrite this method if the plugin expects the incoming requests.diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex aac7293901..a74ec3b94c 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -59,6 +59,7 @@ if TYPE_CHECKING:TokenConfig,TransactionActionData,)+ from ..payment.models import TransactionItemfrom ..product.models import (Category,Collection,@@ -597,6 +598,12 @@ class PluginsManager(PaymentInterface):default_value = Nonereturn self.__run_method_on_plugins("customer_updated", default_value, customer)+ def customer_metadata_updated(self, customer: "User"):+ default_value = None+ return self.__run_method_on_plugins(+ "customer_metadata_updated", default_value, customer+ )+def collection_created(self, collection: "Collection"):default_value = Nonereturn self.__run_method_on_plugins(@@ -615,6 +622,12 @@ class PluginsManager(PaymentInterface):"collection_deleted", default_value, collection)+ def collection_metadata_updated(self, collection: "Collection"):+ default_value = None+ return self.__run_method_on_plugins(+ "collection_metadata_updated", default_value, collection+ )+def product_created(self, product: "Product"):default_value = Nonereturn self.__run_method_on_plugins("product_created", default_value, product)@@ -629,6 +642,12 @@ class PluginsManager(PaymentInterface):"product_deleted", default_value, product, variants)+ def product_metadata_updated(self, product: "Product"):+ default_value = None+ return self.__run_method_on_plugins(+ "product_metadata_updated", default_value, product+ )+def product_variant_created(self, product_variant: "ProductVariant"):default_value = Nonereturn self.__run_method_on_plugins(@@ -661,6 +680,12 @@ class PluginsManager(PaymentInterface):"product_variant_back_in_stock", default_value, stock)+ def product_variant_metadata_updated(self, product_variant: "ProductVariant"):+ default_value = None+ self.__run_method_on_plugins(+ "product_variant_metadata_updated", default_value, product_variant+ )+def order_created(self, order: "Order"):default_value = Nonereturn self.__run_method_on_plugins(@@ -779,6 +804,12 @@ class PluginsManager(PaymentInterface):"order_fulfilled", default_value, order, channel_slug=order.channel.slug)+ def order_metadata_updated(self, order: "Order"):+ default_value = None+ return self.__run_method_on_plugins(+ "order_metadata_updated", default_value, order+ )+def fulfillment_created(self, fulfillment: "Fulfillment"):default_value = Nonereturn self.__run_method_on_plugins(@@ -806,6 +837,12 @@ class PluginsManager(PaymentInterface):channel_slug=fulfillment.order.channel.slug,)+ def fulfillment_metadata_updated(self, fulfillment: "Fulfillment"):+ default_value = None+ return self.__run_method_on_plugins(+ "fulfillment_metadata_updated", default_value, fulfillment+ )+def tracking_number_updated(self, fulfillment: "Fulfillment"):default_value = Nonereturn self.__run_method_on_plugins(@@ -833,6 +870,12 @@ class PluginsManager(PaymentInterface):channel_slug=checkout.channel.slug,)+ def checkout_metadata_updated(self, checkout: "Checkout"):+ default_value = None+ return self.__run_method_on_plugins(+ "checkout_metadata_updated", default_value, checkout+ )+def page_created(self, page: "Page"):default_value = Nonereturn self.__run_method_on_plugins("page_created", default_value, page)@@ -892,6 +935,12 @@ class PluginsManager(PaymentInterface):channel_slug=channel_slug,)+ def transaction_item_metadata_updated(self, transaction_item: "TransactionItem"):+ default_value = None+ return self.__run_method_on_plugins(+ "transaction_item_metadata_updated", default_value, transaction_item+ )+def address_created(self, address: "Address"):default_value = Nonereturn self.__run_method_on_plugins("address_created", default_value, address)@@ -1010,6 +1059,12 @@ class PluginsManager(PaymentInterface):"gift_card_status_changed", default_value, gift_card)+ def gift_card_metadata_updated(self, gift_card: "GiftCard"):+ default_value = None+ return self.__run_method_on_plugins(+ "gift_card_metadata_updated", default_value, gift_card+ )+def menu_created(self, menu: "Menu"):default_value = Nonereturn self.__run_method_on_plugins("menu_created", default_value, menu)@@ -1076,6 +1131,12 @@ class PluginsManager(PaymentInterface):"shipping_zone_deleted", default_value, shipping_zone)+ def shipping_zone_metadata_updated(self, shipping_zone: "ShippingZone"):+ default_value = None+ return self.__run_method_on_plugins(+ "shipping_zone_metadata_updated", default_value, shipping_zone+ )+def staff_created(self, staff_user: "User"):default_value = Nonereturn self.__run_method_on_plugins("staff_created", default_value, staff_user)@@ -1106,6 +1167,12 @@ class PluginsManager(PaymentInterface):"warehouse_deleted", default_value, warehouse)+ def warehouse_metadata_updated(self, warehouse: "Warehouse"):+ default_value = None+ return self.__run_method_on_plugins(+ "warehouse_metadata_updated", default_value, warehouse+ )+def voucher_created(self, voucher: "Voucher"):default_value = Nonereturn self.__run_method_on_plugins("voucher_created", default_value, voucher)@@ -1118,6 +1185,12 @@ class PluginsManager(PaymentInterface):default_value = Nonereturn self.__run_method_on_plugins("voucher_deleted", default_value, voucher)+ def voucher_metadata_updated(self, voucher: "Voucher"):+ default_value = None+ return self.__run_method_on_plugins(+ "voucher_metadata_updated", default_value, voucher+ )+def initialize_payment(self, gateway, payment_data: dict, channel_slug: str) -> Optional["InitializedPaymentResponse"]:diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.pyindex 40cfde0d64..b64b6f472e 100644--- a/saleor/plugins/webhook/plugin.py+++ b/saleor/plugins/webhook/plugin.py@@ -11,7 +11,7 @@ from ...core.notify_events import NotifyEventTypefrom ...core.taxes import TaxData, TaxTypefrom ...core.utils.json_serializer import CustomJsonEncoderfrom ...payment import PaymentError, TransactionKind-from ...payment.models import Payment+from ...payment.models import Payment, TransactionItemfrom ...webhook.event_types import WebhookEventAsyncType, WebhookEventSyncTypefrom ...webhook.payloads import (generate_checkout_payload,@@ -24,6 +24,7 @@ from ...webhook.payloads import (generate_invoice_payload,generate_list_gateways_payload,generate_meta,+ generate_metadata_updated_payload,generate_order_payload,generate_order_payload_for_tax_calculation,generate_page_payload,@@ -118,6 +119,15 @@ class WebhookPlugin(BasePlugin):def _generate_meta(self):return generate_meta(requestor_data=generate_requestor(self.requestor))+ def _trigger_metadata_updated_event(self, event_type, instance):+ if webhooks := get_webhooks_for_event(event_type):+ metadata_updated_data = generate_metadata_updated_payload(+ instance, self.requestor+ )+ trigger_webhooks_async(+ metadata_updated_data, event_type, webhooks, instance, self.requestor+ )+def _trigger_address_event(self, event_type, address):if webhooks := get_webhooks_for_event(event_type):payload = self._serialize_payload(@@ -358,6 +368,15 @@ class WebhookPlugin(BasePlugin):WebhookEventAsyncType.GIFT_CARD_DELETED, gift_card)+ def gift_card_metadata_updated(+ self, gift_card: "GiftCard", previous_value: None+ ) -> None:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED, gift_card+ )+def gift_card_status_changed(self, gift_card: "GiftCard", previous_value: None) -> None:@@ -598,6 +617,13 @@ class WebhookPlugin(BasePlugin):order_data, event_type, webhooks, order, self.requestor)+ def order_metadata_updated(self, order: "Order", previous_value: Any) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.ORDER_METADATA_UPDATED, order+ )+def draft_order_created(self, order: "Order", previous_value: Any) -> Any:if not self.active:return previous_value@@ -658,6 +684,13 @@ class WebhookPlugin(BasePlugin):fulfillment_data, event_type, webhooks, fulfillment, self.requestor)+ def fulfillment_metadata_updated(self, fulfillment: "Fulfillment", previous_value):+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED, fulfillment+ )+def customer_created(self, customer: "User", previous_value: Any) -> Any:if not self.active:return previous_value@@ -688,6 +721,13 @@ class WebhookPlugin(BasePlugin):customer_data, event_type, webhooks, customer, self.requestor)+ def customer_metadata_updated(self, customer: "User", previous_value: Any) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED, customer+ )+def collection_created(self, collection: "Collection", previous_value: Any) -> Any:if not self.active:return previous_value@@ -718,6 +758,15 @@ class WebhookPlugin(BasePlugin):collection_data, event_type, webhooks, collection, self.requestor)+ def collection_metadata_updated(+ self, collection: "Collection", previous_value: Any+ ) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.COLLECTION_METADATA_UPDATED, collection+ )+def product_created(self, product: "Product", previous_value: Any) -> Any:if not self.active:return previous_value@@ -738,6 +787,13 @@ class WebhookPlugin(BasePlugin):product_data, event_type, webhooks, product, self.requestor)+ def product_metadata_updated(self, product: "Product", previous_value: Any) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.PRODUCT_METADATA_UPDATED, product+ )+def product_deleted(self, product: "Product", variants: List[int], previous_value: Any) -> Any:@@ -810,6 +866,15 @@ class WebhookPlugin(BasePlugin):self.requestor,)+ def product_variant_metadata_updated(+ self, product_variant: "ProductVariant", previous_value: Any+ ) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED, product_variant+ )+def product_variant_out_of_stock(self, stock: "Stock", previous_value: Any) -> Any:if not self.active:return previous_value@@ -852,6 +917,15 @@ class WebhookPlugin(BasePlugin):checkout_data, event_type, webhooks, checkout, self.requestor)+ def checkout_metadata_updated(+ self, checkout: "Checkout", previous_value: Any+ ) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED, checkout+ )+def notify(self, event: Union[NotifyEventType, str], payload: dict, previous_value) -> Any:@@ -1049,6 +1123,15 @@ class WebhookPlugin(BasePlugin):WebhookEventAsyncType.SHIPPING_ZONE_DELETED, shipping_zone)+ def shipping_zone_metadata_updated(+ self, shipping_zone: "ShippingZone", previous_value: Any+ ) -> Any:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED, shipping_zone+ )+def _trigger_staff_event(self, event_type, staff_user):if webhooks := get_webhooks_for_event(event_type):payload = self._serialize_payload(@@ -1130,6 +1213,15 @@ class WebhookPlugin(BasePlugin):WebhookEventAsyncType.WAREHOUSE_DELETED, warehouse)+ def warehouse_metadata_updated(+ self, warehouse: "Warehouse", previous_value: None+ ) -> None:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED, warehouse+ )+def _trigger_voucher_event(self, event_type, voucher):if webhooks := get_webhooks_for_event(event_type):payload = self._serialize_payload(@@ -1159,6 +1251,15 @@ class WebhookPlugin(BasePlugin):return previous_valueself._trigger_voucher_event(WebhookEventAsyncType.VOUCHER_DELETED, voucher)+ def voucher_metadata_updated(+ self, voucher: "Voucher", previous_value: None+ ) -> None:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.VOUCHER_METADATA_UPDATED, voucher+ )+def event_delivery_retry(self, delivery: "EventDelivery", previous_value: Any):if not self.active:return previous_value@@ -1278,6 +1379,15 @@ class WebhookPlugin(BasePlugin):gateways.extend(app_gateways)return gateways+ def transaction_item_metadata_updated(+ self, transaction_item: "TransactionItem", previous_value: None+ ) -> None:+ if not self.active:+ return previous_value+ self._trigger_metadata_updated_event(+ WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED, transaction_item+ )+def authorize_payment(self, payment_information: "PaymentData", previous_value, **kwargs) -> "GatewayResponse":diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.pyindex 3d81cd89bf..7a2a9c0723 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py@@ -190,6 +190,14 @@ def subscription_gift_card_status_changed_webhook(subscription_webhook):)+def subscription_gift_card_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.GIFT_CARD_METADATA_UPDATED,+ WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_menu_created_webhook(subscription_webhook):return subscription_webhook(@@ -280,6 +288,14 @@ def subscription_shipping_zone_deleted_webhook(subscription_webhook):)+def subscription_shipping_zone_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.SHIPPING_ZONE_METADATA_UPDATED,+ WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_product_updated_webhook(subscription_webhook):return subscription_webhook(@@ -301,6 +317,13 @@ def subscription_product_deleted_webhook(subscription_webhook):)+def subscription_product_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.PRODUCT_METADATA_UPDATED, WebhookEventAsyncType.PRODUCT_METADATA_UPDATED+ )++@pytest.fixturedef subscription_product_variant_created_webhook(subscription_webhook):return subscription_webhook(@@ -325,6 +348,14 @@ def subscription_product_variant_deleted_webhook(subscription_webhook):)+def subscription_product_variant_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.PRODUCT_VARIANT_METADATA_UPDATED,+ WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_product_variant_out_of_stock_webhook(subscription_webhook):return subscription_webhook(@@ -383,6 +414,13 @@ def subscription_order_fulfilled_webhook(subscription_webhook):)+def subscription_order_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.ORDER_METADATA_UPDATED, WebhookEventAsyncType.ORDER_METADATA_UPDATED+ )++@pytest.fixturedef subscription_draft_order_created_webhook(subscription_webhook):return subscription_webhook(@@ -478,6 +516,14 @@ def subscription_fulfillment_approved_webhook(subscription_webhook):)+def subscription_fulfillment_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.FULFILLMENT_METADATA_UPDATED,+ WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_customer_created_webhook(subscription_webhook):return subscription_webhook(@@ -499,6 +545,14 @@ def subscription_customer_deleted_webhook(subscription_webhook):)+def subscription_customer_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.CUSTOMER_METADATA_UPDATED,+ WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_collection_created_webhook(subscription_webhook):return subscription_webhook(@@ -523,6 +577,14 @@ def subscription_collection_deleted_webhook(subscription_webhook):)+def subscription_collection_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.COLLECTION_METADATA_UPDATED,+ WebhookEventAsyncType.COLLECTION_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_checkout_created_webhook(subscription_webhook):return subscription_webhook(@@ -537,6 +599,14 @@ def subscription_checkout_updated_webhook(subscription_webhook):)+def subscription_checkout_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.CHECKOUT_METADATA_UPDATED,+ WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_page_created_webhook(subscription_webhook):return subscription_webhook(@@ -636,6 +706,14 @@ def subscription_staff_deleted_webhook(subscription_webhook):)+def subscription_transaction_item_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.TRANSACTION_ITEM_METADATA_UPDATED,+ WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_translation_created_webhook(subscription_webhook):return subscription_webhook(@@ -673,6 +751,14 @@ def subscription_warehouse_deleted_webhook(subscription_webhook):)+def subscription_warehouse_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.WAREHOUSE_METADATA_UPDATED,+ WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED,+ )++@pytest.fixturedef subscription_voucher_created_webhook(subscription_webhook):return subscription_webhook(@@ -702,6 +788,13 @@ def subscription_voucher_webhook_with_meta(subscription_webhook):)+def subscription_voucher_metadata_updated_webhook(subscription_webhook):+ return subscription_webhook(+ queries.VOUCHER_METADATA_UPDATED, WebhookEventAsyncType.VOUCHER_METADATA_UPDATED+ )++@pytest.fixturedef subscription_payment_authorize_webhook(subscription_webhook):return subscription_webhook(diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.pyindex 6acf77d4c1..0e797a4e30 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py@@ -47,7 +47,6 @@ ADDRESS_DELETED = (""")-APP_INSTALLED = (fragments.APP_DETAILS+ """@@ -269,6 +268,20 @@ GIFT_CARD_STATUS_CHANGED = (""")+GIFT_CARD_METADATA_UPDATED = (+ fragments.GIFT_CARD_DETAILS+ + """+ subscription{+ event{+ ...on GiftCardMetadataUpdated{+ giftCard{+ ...GiftCardDetails+ }+ }+ }+ }+"""+)VOUCHER_CREATED = (fragments.VOUCHER_DETAILS@@ -350,6 +363,21 @@ VOUCHER_DELETED = (""")+VOUCHER_METADATA_UPDATED = (+ fragments.VOUCHER_DETAILS+ + """+ subscription{+ event{+ ...on VoucherMetadataUpdated{+ voucher{+ ...VoucherDetails+ }+ }+ }+ }+"""+)+CHANNEL_CREATED = """subscription{@@ -546,6 +574,25 @@ SHIPPING_ZONE_DELETED = """}"""+SHIPPING_ZONE_METADATA_UPDATED = """+ subscription{+ event{+ ...on ShippingZoneMetadataUpdated{+ shippingZone{+ id+ name+ countries {+ code+ }+ channels {+ name+ }+ }+ }+ }+ }+"""+STAFF_CREATED = (fragments.STAFF_DETAILS+ """@@ -629,6 +676,18 @@ PRODUCT_DELETED = """}"""+PRODUCT_METADATA_UPDATED = """+ subscription{+ event{+ ...on ProductMetadataUpdated{+ product{+ id+ }+ }+ }+ }+"""+PRODUCT_VARIANT_CREATED = """subscription{event{@@ -666,6 +725,18 @@ PRODUCT_VARIANT_DELETED = """}"""+PRODUCT_VARIANT_METADATA_UPDATED = """+ subscription{+ event{+ ...on ProductVariantMetadataUpdated{+ productVariant{+ id+ }+ }+ }+ }+"""+PRODUCT_VARIANT_OUT_OF_STOCK = """subscription{event{@@ -762,6 +833,18 @@ ORDER_FULFILLED = """}"""+ORDER_METADATA_UPDATED = """+ subscription{+ event{+ ...on OrderMetadataUpdated{+ order{+ id+ }+ }+ }+ }+"""+DRAFT_ORDER_CREATED = """subscription{event{@@ -958,6 +1041,26 @@ FULFILLMENT_APPROVED = (""")++FULFILLMENT_METADATA_UPDATED = (+ fragments.FULFILLMENT_DETAILS+ + """+ subscription{+ event{+ ...on FulfillmentMetadataUpdated{+ fulfillment{+ ...FulfillmentDetails+ }+ order{+ id+ }+ }+ }+ }+"""+)++CUSTOMER_CREATED = (fragments.CUSTOMER_DETAILS+ """@@ -1005,6 +1108,22 @@ CUSTOMER_DELETED = ()+CUSTOMER_METADATA_UPDATED = (+ fragments.CUSTOMER_DETAILS+ + """+ subscription{+ event{+ ...on CustomerMetadataUpdated{+ user{+ ...CustomerDetails+ }+ }+ }+ }+"""+)++COLLECTION_CREATED = (fragments.COLLECTION+ """@@ -1052,6 +1171,22 @@ COLLECTION_DELETED = ()+COLLECTION_METADATA_UPDATED = (+ fragments.COLLECTION+ + """+ subscription{+ event{+ ...on CollectionMetadataUpdated{+ collection(channel: "main"){+ ...CollectionDetails+ }+ }+ }+ }+ """+)++CHECKOUT_CREATED = """subscription{event{@@ -1079,6 +1214,18 @@ CHECKOUT_UPDATED = """}"""+CHECKOUT_METADATA_UPDATED = """+ subscription{+ event{+ ...on CheckoutMetadataUpdated{+ checkout{+ id+ }+ }+ }+ }+"""+PAGE_CREATED = (fragments.PAGE_DETAILS+ """@@ -1216,6 +1363,19 @@ PERMISSION_GROUP_DELETED = ()+TRANSACTION_ITEM_METADATA_UPDATED = """+ subscription{+ event{+ ...on TransactionItemMetadataUpdated{+ transaction {+ id+ }+ }+ }+ }+ """++MULTIPLE_EVENTS = """subscription{event{@@ -1571,6 +1731,21 @@ WAREHOUSE_DELETED = (""")+WAREHOUSE_METADATA_UPDATED = (+ fragments.WAREHOUSE_DETAILS+ + """+ subscription{+ event{+ ...on WarehouseMetadataUpdated{+ warehouse{+ ...WarehouseDetails+ }+ }+ }+ }+"""+)+PAYMENT_AUTHORIZE = (fragments.PAYMENT_DETAILS+ """diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.pyindex 11e0aeb48d..fe26dd7d86 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py@@ -546,6 +546,24 @@ def test_gift_card_status_changed(assert deliveries[0].webhook == webhooks[0]+def test_gift_card_metadata_updated(+ gift_card, subscription_gift_card_metadata_updated_webhook+):+ # given+ webhooks = [subscription_gift_card_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED+ gift_card_id = graphene.Node.to_global_id("GiftCard", gift_card.id)++ # when+ deliveries = create_deliveries_for_subscriptions(event_type, gift_card, webhooks)++ # then+ expected_payload = generate_gift_card_payload(gift_card, gift_card_id)+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_menu_created(menu, subscription_menu_created_webhook):# givenwebhooks = [subscription_menu_created_webhook]@@ -817,6 +835,35 @@ def test_shipping_zone_deleted(assert deliveries[0].webhook == webhooks[0]+def test_shipping_zone_metadata_updated(+ shipping_zone, subscription_shipping_zone_metadata_updated_webhook+):+ # given+ webhooks = [subscription_shipping_zone_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED+ shipping_zone_id = graphene.Node.to_global_id("ShippingZone", shipping_zone.id)++ # when+ deliveries = create_deliveries_for_subscriptions(+ event_type, shipping_zone, webhooks+ )++ # then+ expected_payload = json.dumps(+ {+ "shippingZone": {+ "id": shipping_zone_id,+ "name": shipping_zone.name,+ "countries": [{"code": c.code} for c in shipping_zone.countries],+ "channels": [{"name": c.name} for c in shipping_zone.channels.all()],+ }+ }+ )+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_staff_created(staff_user, subscription_staff_created_webhook):# givenwebhooks = [subscription_staff_created_webhook]@@ -903,6 +950,20 @@ def test_product_deleted(product, subscription_product_deleted_webhook):assert deliveries[0].webhook == webhooks[0]+def test_product_metadata_updated(+ product, subscription_product_metadata_updated_webhook+):+ webhooks = [subscription_product_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.PRODUCT_METADATA_UPDATED+ product_id = graphene.Node.to_global_id("Product", product.id)+ deliveries = create_deliveries_for_subscriptions(event_type, product, webhooks)+ expected_payload = json.dumps({"product": {"id": product_id}})++ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_product_variant_created(variant, subscription_product_variant_created_webhook):webhooks = [subscription_product_variant_created_webhook]event_type = WebhookEventAsyncType.PRODUCT_VARIANT_CREATED@@ -939,6 +1000,20 @@ def test_product_variant_deleted(variant, subscription_product_variant_deleted_wassert deliveries[0].webhook == webhooks[0]+def test_product_variant_metadata_updated(+ variant, subscription_product_variant_metadata_updated_webhook+):+ webhooks = [subscription_product_variant_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)+ deliveries = create_deliveries_for_subscriptions(event_type, variant, webhooks)+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})++ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_product_variant_out_of_stock(stock, subscription_product_variant_out_of_stock_webhook):@@ -1039,6 +1114,18 @@ def test_order_fulfilled(order, subscription_order_fulfilled_webhook):assert deliveries[0].webhook == webhooks[0]+def test_order_metadata_updated(order, subscription_order_metadata_updated_webhook):+ webhooks = [subscription_order_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.ORDER_METADATA_UPDATED+ order_id = graphene.Node.to_global_id("Order", order.id)+ deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)+ expected_payload = json.dumps({"order": {"id": order_id}})++ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_draft_order_created(order, subscription_draft_order_created_webhook):webhooks = [subscription_draft_order_created_webhook]event_type = WebhookEventAsyncType.DRAFT_ORDER_CREATED@@ -1228,6 +1315,23 @@ def test_fulfillment_approved(fulfillment, subscription_fulfillment_approved_webassert deliveries[0].webhook == webhooks[0]+def test_fulfillment_metadata_updated(+ fulfillment, subscription_fulfillment_metadata_updated_webhook+):+ # given+ webhooks = [subscription_fulfillment_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED+ expected_payload = generate_fulfillment_payload(fulfillment)++ # when+ deliveries = create_deliveries_for_subscriptions(event_type, fulfillment, webhooks)++ # then+ assert deliveries[0].payload.payload == json.dumps(expected_payload)+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_customer_created(customer_user, subscription_customer_created_webhook):# givenwebhooks = [subscription_customer_created_webhook]@@ -1283,6 +1387,25 @@ def test_customer_deleted(customer_user, subscription_customer_created_webhook):assert deliveries[0].webhook == webhooks[0]+def test_customer_metadata_updated(+ customer_user, subscription_customer_metadata_updated_webhook+):+ # given+ webhooks = [subscription_customer_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED+ expected_payload = json.dumps(generate_customer_payload(customer_user))++ # when+ deliveries = create_deliveries_for_subscriptions(+ event_type, customer_user, webhooks+ )++ # then+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_collection_created(collection_with_products, subscription_collection_created_webhook):@@ -1337,6 +1460,24 @@ def test_collection_deleted(assert deliveries[0].webhook == webhooks[0]+def test_collection_metadata_updated(+ collection_with_products, subscription_collection_metadata_updated_webhook+):+ # given+ webhooks = [subscription_collection_metadata_updated_webhook]+ collection = collection_with_products[0].collections.first()+ event_type = WebhookEventAsyncType.COLLECTION_METADATA_UPDATED+ expected_payload = generate_collection_payload(collection)++ # when+ deliveries = create_deliveries_for_subscriptions(event_type, collection, webhooks)++ # then+ assert deliveries[0].payload.payload == json.dumps(expected_payload)+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_checkout_create(checkout, subscription_checkout_created_webhook):webhooks = [subscription_checkout_created_webhook]event_type = WebhookEventAsyncType.CHECKOUT_CREATED@@ -1362,6 +1503,20 @@ def test_checkout_update(checkout, subscription_checkout_updated_webhook):assert deliveries[0].webhook == webhooks[0]+def test_checkout_metadata_updated(+ checkout, subscription_checkout_metadata_updated_webhook+):+ webhooks = [subscription_checkout_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED+ checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)+ deliveries = create_deliveries_for_subscriptions(event_type, checkout, webhooks)+ expected_payload = json.dumps({"checkout": {"id": checkout_id}})++ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_page_created(page, subscription_page_created_webhook):# givenwebhooks = [subscription_page_created_webhook]@@ -1549,13 +1704,13 @@ def test_warehouse_updated(warehouse, subscription_warehouse_updated_webhook):# givenwebhooks = [subscription_warehouse_updated_webhook]event_type = WebhookEventAsyncType.WAREHOUSE_UPDATED- voucher_id = graphene.Node.to_global_id("Warehouse", warehouse.id)+ warehouse_id = graphene.Node.to_global_id("Warehouse", warehouse.id)# whendeliveries = create_deliveries_for_subscriptions(event_type, warehouse, webhooks)# then- expected_payload = generate_warehouse_payload(warehouse, voucher_id)+ expected_payload = generate_warehouse_payload(warehouse, warehouse_id)assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -1584,6 +1739,24 @@ def test_warehouse_deleted(warehouse, subscription_warehouse_deleted_webhook):assert deliveries[0].webhook == webhooks[0]+def test_warehouse_metadata_updated(+ warehouse, subscription_warehouse_metadata_updated_webhook+):+ # given+ webhooks = [subscription_warehouse_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED+ warehouse_id = graphene.Node.to_global_id("Warehouse", warehouse.id)++ # when+ deliveries = create_deliveries_for_subscriptions(event_type, warehouse, webhooks)++ # then+ expected_payload = generate_warehouse_payload(warehouse, warehouse_id)+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_voucher_created(voucher, subscription_voucher_created_webhook):# givenwebhooks = [subscription_voucher_created_webhook]@@ -1637,6 +1810,46 @@ def test_voucher_deleted(voucher, subscription_voucher_deleted_webhook):assert deliveries[0].webhook == webhooks[0]+def test_voucher_metadata_updated(+ voucher, subscription_voucher_metadata_updated_webhook+):+ # given+ webhooks = [subscription_voucher_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.VOUCHER_METADATA_UPDATED+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)++ # when+ deliveries = create_deliveries_for_subscriptions(event_type, voucher, webhooks)++ # then+ expected_payload = generate_voucher_payload(voucher, voucher_id)+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]+++def test_transaction_item_metadata_updated(+ transaction_item, subscription_transaction_item_metadata_updated_webhook+):+ # given+ webhooks = [subscription_transaction_item_metadata_updated_webhook]+ event_type = WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED+ transaction_item_id = graphene.Node.to_global_id(+ "TransactionItem", transaction_item.id+ )++ # when+ deliveries = create_deliveries_for_subscriptions(+ event_type, transaction_item, webhooks+ )++ # then+ expected_payload = json.dumps({"transaction": {"id": transaction_item_id}})+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]++def test_shipping_list_methods_for_checkout(checkout_with_shipping_required,subscription_shipping_list_methods_for_checkout_webhook,diff --git a/saleor/plugins/webhook/tests/test_webhook.py b/saleor/plugins/webhook/tests/test_webhook.pyindex 08f7a24ba9..be53df9963 100644--- a/saleor/plugins/webhook/tests/test_webhook.py+++ b/saleor/plugins/webhook/tests/test_webhook.py@@ -40,6 +40,7 @@ from ....webhook.payloads import (generate_collection_payload,generate_customer_payload,generate_invoice_payload,+ generate_metadata_updated_payload,generate_order_payload,generate_page_payload,generate_product_deleted_payload,@@ -297,6 +298,31 @@ def test_customer_updated()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_customer_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ customer_user,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.customer_metadata_updated(customer_user)+ expected_data = generate_metadata_updated_payload(customer_user)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.CUSTOMER_METADATA_UPDATED,+ [any_webhook],+ customer_user,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -397,6 +423,31 @@ def test_collection_deleted()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_collection_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ collection,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.collection_metadata_updated(collection)+ expected_data = generate_metadata_updated_payload(collection)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.COLLECTION_METADATA_UPDATED,+ [any_webhook],+ collection,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -487,6 +538,31 @@ def test_product_deleted()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_product_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ product,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.product_metadata_updated(product)+ expected_data = generate_metadata_updated_payload(product)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.PRODUCT_METADATA_UPDATED,+ [any_webhook],+ product,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -562,6 +638,31 @@ def test_product_variant_deleted()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_product_variant_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ variant,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.product_variant_metadata_updated(variant)+ expected_data = generate_metadata_updated_payload(variant)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.PRODUCT_VARIANT_METADATA_UPDATED,+ [any_webhook],+ variant,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -664,6 +765,31 @@ def test_order_cancelled()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_order_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ order_with_lines,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.order_metadata_updated(order_with_lines)+ expected_data = generate_metadata_updated_payload(order_with_lines)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.ORDER_METADATA_UPDATED,+ [any_webhook],+ order_with_lines,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -736,6 +862,31 @@ def test_checkout_updated()+@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_checkout_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ checkout_with_items,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.checkout_metadata_updated(checkout_with_items)+ expected_data = generate_metadata_updated_payload(checkout_with_items)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.CHECKOUT_METADATA_UPDATED,+ [any_webhook],+ checkout_with_items,+ None,+ )++@freeze_time("1914-06-28 10:50")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -864,6 +1015,156 @@ def test_invoice_sent()+@freeze_time("2020-03-18 12:00:00")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_fulfillment_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ fulfillment,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.fulfillment_metadata_updated(fulfillment)+ expected_data = generate_metadata_updated_payload(fulfillment)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.FULFILLMENT_METADATA_UPDATED,+ [any_webhook],+ fulfillment,+ None,+ )+++@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_gift_card_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ gift_card,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.gift_card_metadata_updated(gift_card)+ expected_data = generate_metadata_updated_payload(gift_card)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.GIFT_CARD_METADATA_UPDATED,+ [any_webhook],+ gift_card,+ None,+ )+++@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_voucher_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ voucher,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.voucher_metadata_updated(voucher)+ expected_data = generate_metadata_updated_payload(voucher)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.VOUCHER_METADATA_UPDATED,+ [any_webhook],+ voucher,+ None,+ )+++@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_shipping_zone_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ shipping_zone,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.shipping_zone_metadata_updated(shipping_zone)+ expected_data = generate_metadata_updated_payload(shipping_zone)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.SHIPPING_ZONE_METADATA_UPDATED,+ [any_webhook],+ shipping_zone,+ None,+ )+++@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_warehouse_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ warehouse,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.warehouse_metadata_updated(warehouse)+ expected_data = generate_metadata_updated_payload(warehouse)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.WAREHOUSE_METADATA_UPDATED,+ [any_webhook],+ warehouse,+ None,+ )+++@freeze_time("1914-06-28 10:50")[email protected]("saleor.plugins.webhook.plugin.get_webhooks_for_event")[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_async")+def test_transaction_item_metadata_updated(+ mocked_webhook_trigger,+ mocked_get_webhooks_for_event,+ any_webhook,+ settings,+ transaction_item,+):+ mocked_get_webhooks_for_event.return_value = [any_webhook]+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]+ manager = get_plugins_manager()+ manager.transaction_item_metadata_updated(transaction_item)+ expected_data = generate_metadata_updated_payload(transaction_item)++ mocked_webhook_trigger.assert_called_once_with(+ expected_data,+ WebhookEventAsyncType.TRANSACTION_ITEM_METADATA_UPDATED,+ [any_webhook],+ transaction_item,+ None,+ )++@freeze_time("2020-03-18 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")diff --git a/saleor/webhook/event_types.py b/saleor/webhook/event_types.pyindex f7577d6b4d..a8590e2c8b 100644--- a/saleor/webhook/event_types.py+++ b/saleor/webhook/event_types.py@@ -49,6 +49,7 @@ class WebhookEventAsyncType:GIFT_CARD_UPDATED = "gift_card_updated"GIFT_CARD_DELETED = "gift_card_deleted"GIFT_CARD_STATUS_CHANGED = "gift_card_status_changed"+ GIFT_CARD_METADATA_UPDATED = "gift_card_metadata_updated"MENU_CREATED = "menu_created"MENU_UPDATED = "menu_updated"@@ -63,10 +64,12 @@ class WebhookEventAsyncType:ORDER_UPDATED = "order_updated"ORDER_CANCELLED = "order_cancelled"ORDER_FULFILLED = "order_fulfilled"+ ORDER_METADATA_UPDATED = "order_metadata_updated"FULFILLMENT_CREATED = "fulfillment_created"FULFILLMENT_CANCELED = "fulfillment_canceled"FULFILLMENT_APPROVED = "fulfillment_approved"+ FULFILLMENT_METADATA_UPDATED = "fulfillment_metadata_updated"DRAFT_ORDER_CREATED = "draft_order_created"DRAFT_ORDER_UPDATED = "draft_order_updated"@@ -84,24 +87,29 @@ class WebhookEventAsyncType:CUSTOMER_CREATED = "customer_created"CUSTOMER_UPDATED = "customer_updated"CUSTOMER_DELETED = "customer_deleted"+ CUSTOMER_METADATA_UPDATED = "customer_metadata_updated"COLLECTION_CREATED = "collection_created"COLLECTION_UPDATED = "collection_updated"COLLECTION_DELETED = "collection_deleted"+ COLLECTION_METADATA_UPDATED = "collection_metadata_updated"PRODUCT_CREATED = "product_created"PRODUCT_UPDATED = "product_updated"PRODUCT_DELETED = "product_deleted"+ PRODUCT_METADATA_UPDATED = "product_metadata_updated"PRODUCT_VARIANT_CREATED = "product_variant_created"PRODUCT_VARIANT_UPDATED = "product_variant_updated"PRODUCT_VARIANT_DELETED = "product_variant_deleted"+ PRODUCT_VARIANT_METADATA_UPDATED = "product_variant_metadata_updated"PRODUCT_VARIANT_OUT_OF_STOCK = "product_variant_out_of_stock"PRODUCT_VARIANT_BACK_IN_STOCK = "product_variant_back_in_stock"CHECKOUT_CREATED = "checkout_created"CHECKOUT_UPDATED = "checkout_updated"+ CHECKOUT_METADATA_UPDATED = "checkout_metadata_updated"NOTIFY_USER = "notify_user"@@ -124,12 +132,14 @@ class WebhookEventAsyncType:SHIPPING_ZONE_CREATED = "shipping_zone_created"SHIPPING_ZONE_UPDATED = "shipping_zone_updated"SHIPPING_ZONE_DELETED = "shipping_zone_deleted"+ SHIPPING_ZONE_METADATA_UPDATED = "shipping_zone_metadata_updated"STAFF_CREATED = "staff_created"STAFF_UPDATED = "staff_updated"STAFF_DELETED = "staff_deleted"TRANSACTION_ACTION_REQUEST = "transaction_action_request"+ TRANSACTION_ITEM_METADATA_UPDATED = "transaction_item_metadata_updated"TRANSLATION_CREATED = "translation_created"TRANSLATION_UPDATED = "translation_updated"@@ -137,10 +147,12 @@ class WebhookEventAsyncType:WAREHOUSE_CREATED = "warehouse_created"WAREHOUSE_UPDATED = "warehouse_updated"WAREHOUSE_DELETED = "warehouse_deleted"+ WAREHOUSE_METADATA_UPDATED = "warehouse_metadata_updated"VOUCHER_CREATED = "voucher_created"VOUCHER_UPDATED = "voucher_updated"VOUCHER_DELETED = "voucher_deleted"+ VOUCHER_METADATA_UPDATED = "voucher_metadata_updated"OBSERVABILITY = "observability"@@ -170,6 +182,7 @@ class WebhookEventAsyncType:GIFT_CARD_UPDATED: "Gift card updated",GIFT_CARD_DELETED: "Gift card deleted",GIFT_CARD_STATUS_CHANGED: "Gift card status changed",+ GIFT_CARD_METADATA_UPDATED: "Gift card metadata updated",MENU_CREATED: "Menu created",MENU_UPDATED: "Menu updated",MENU_DELETED: "Menu deleted",@@ -182,6 +195,7 @@ class WebhookEventAsyncType:ORDER_UPDATED: "Order updated",ORDER_CANCELLED: "Order cancelled",ORDER_FULFILLED: "Order fulfilled",+ ORDER_METADATA_UPDATED: "Order metadata updated",DRAFT_ORDER_CREATED: "Draft order created",DRAFT_ORDER_UPDATED: "Draft order updated",DRAFT_ORDER_DELETED: "Draft order deleted",@@ -195,22 +209,28 @@ class WebhookEventAsyncType:CUSTOMER_CREATED: "Customer created",CUSTOMER_UPDATED: "Customer updated",CUSTOMER_DELETED: "Customer deleted",+ CUSTOMER_METADATA_UPDATED: "Customer metadata updated",COLLECTION_CREATED: "Collection created",COLLECTION_UPDATED: "Collection updated",COLLECTION_DELETED: "Collection deleted",+ COLLECTION_METADATA_UPDATED: "Collection metadata updated",PRODUCT_CREATED: "Product created",PRODUCT_UPDATED: "Product updated",PRODUCT_DELETED: "Product deleted",+ PRODUCT_METADATA_UPDATED: "Product metadata updated",PRODUCT_VARIANT_CREATED: "Product variant created",PRODUCT_VARIANT_UPDATED: "Product variant updated",PRODUCT_VARIANT_DELETED: "Product variant deleted",+ PRODUCT_VARIANT_METADATA_UPDATED: "Product variant metadata updated",PRODUCT_VARIANT_OUT_OF_STOCK: "Product variant stock changed",PRODUCT_VARIANT_BACK_IN_STOCK: "Product variant back in stock",CHECKOUT_CREATED: "Checkout created",CHECKOUT_UPDATED: "Checkout updated",+ CHECKOUT_METADATA_UPDATED: "Checkout metadata updated",FULFILLMENT_CREATED: "Fulfillment created",FULFILLMENT_CANCELED: "Fulfillment cancelled",FULFILLMENT_APPROVED: "Fulfillment approved",+ FULFILLMENT_METADATA_UPDATED: "Fulfillment metadata updated",NOTIFY_USER: "Notify user",PAGE_CREATED: "Page Created",PAGE_UPDATED: "Page Updated",@@ -227,18 +247,22 @@ class WebhookEventAsyncType:SHIPPING_ZONE_CREATED: "Shipping zone created",SHIPPING_ZONE_UPDATED: "Shipping zone updated",SHIPPING_ZONE_DELETED: "Shipping zone deleted",+ SHIPPING_ZONE_METADATA_UPDATED: "Shipping zone metadata updated",STAFF_CREATED: "Staff created",STAFF_UPDATED: "Staff updated",STAFF_DELETED: "Staff deleted",TRANSACTION_ACTION_REQUEST: "Payment action request",+ TRANSACTION_ITEM_METADATA_UPDATED: "Transaction item metadata updated",TRANSLATION_CREATED: "Create translation",TRANSLATION_UPDATED: "Update translation",WAREHOUSE_CREATED: "Warehouse created",WAREHOUSE_UPDATED: "Warehouse updated",WAREHOUSE_DELETED: "Warehouse deleted",+ WAREHOUSE_METADATA_UPDATED: "Warehouse metadata updated",VOUCHER_CREATED: "Voucher created",VOUCHER_UPDATED: "Voucher updated",VOUCHER_DELETED: "Voucher deleted",+ VOUCHER_METADATA_UPDATED: "Voucher metadata updated",OBSERVABILITY: "Observability",}@@ -268,6 +292,7 @@ class WebhookEventAsyncType:(GIFT_CARD_UPDATED, DISPLAY_LABELS[GIFT_CARD_UPDATED]),(GIFT_CARD_DELETED, DISPLAY_LABELS[GIFT_CARD_DELETED]),(GIFT_CARD_STATUS_CHANGED, DISPLAY_LABELS[GIFT_CARD_STATUS_CHANGED]),+ (GIFT_CARD_METADATA_UPDATED, DISPLAY_LABELS[GIFT_CARD_METADATA_UPDATED]),(MENU_CREATED, DISPLAY_LABELS[MENU_CREATED]),(MENU_UPDATED, DISPLAY_LABELS[MENU_UPDATED]),(MENU_DELETED, DISPLAY_LABELS[MENU_DELETED]),@@ -280,6 +305,7 @@ class WebhookEventAsyncType:(ORDER_UPDATED, DISPLAY_LABELS[ORDER_UPDATED]),(ORDER_CANCELLED, DISPLAY_LABELS[ORDER_CANCELLED]),(ORDER_FULFILLED, DISPLAY_LABELS[ORDER_FULFILLED]),+ (ORDER_METADATA_UPDATED, DISPLAY_LABELS[ORDER_METADATA_UPDATED]),(DRAFT_ORDER_CREATED, DISPLAY_LABELS[DRAFT_ORDER_CREATED]),(DRAFT_ORDER_UPDATED, DISPLAY_LABELS[DRAFT_ORDER_UPDATED]),(DRAFT_ORDER_DELETED, DISPLAY_LABELS[DRAFT_ORDER_DELETED]),@@ -293,22 +319,31 @@ class WebhookEventAsyncType:(CUSTOMER_CREATED, DISPLAY_LABELS[CUSTOMER_CREATED]),(CUSTOMER_UPDATED, DISPLAY_LABELS[CUSTOMER_UPDATED]),(CUSTOMER_DELETED, DISPLAY_LABELS[CUSTOMER_DELETED]),+ (CUSTOMER_METADATA_UPDATED, DISPLAY_LABELS[CUSTOMER_METADATA_UPDATED]),(COLLECTION_CREATED, DISPLAY_LABELS[COLLECTION_CREATED]),(COLLECTION_UPDATED, DISPLAY_LABELS[COLLECTION_UPDATED]),(COLLECTION_DELETED, DISPLAY_LABELS[COLLECTION_DELETED]),+ (COLLECTION_METADATA_UPDATED, DISPLAY_LABELS[COLLECTION_METADATA_UPDATED]),(PRODUCT_CREATED, DISPLAY_LABELS[PRODUCT_CREATED]),(PRODUCT_UPDATED, DISPLAY_LABELS[PRODUCT_UPDATED]),(PRODUCT_DELETED, DISPLAY_LABELS[PRODUCT_DELETED]),+ (PRODUCT_METADATA_UPDATED, DISPLAY_LABELS[PRODUCT_METADATA_UPDATED]),(PRODUCT_VARIANT_CREATED, DISPLAY_LABELS[PRODUCT_VARIANT_CREATED]),(PRODUCT_VARIANT_UPDATED, DISPLAY_LABELS[PRODUCT_VARIANT_UPDATED]),(PRODUCT_VARIANT_DELETED, DISPLAY_LABELS[PRODUCT_VARIANT_DELETED]),(PRODUCT_VARIANT_OUT_OF_STOCK, DISPLAY_LABELS[PRODUCT_VARIANT_OUT_OF_STOCK]),(PRODUCT_VARIANT_BACK_IN_STOCK, DISPLAY_LABELS[PRODUCT_VARIANT_BACK_IN_STOCK]),+ (+ PRODUCT_VARIANT_METADATA_UPDATED,+ DISPLAY_LABELS[PRODUCT_VARIANT_METADATA_UPDATED],+ ),(CHECKOUT_CREATED, DISPLAY_LABELS[CHECKOUT_CREATED]),(CHECKOUT_UPDATED, DISPLAY_LABELS[CHECKOUT_UPDATED]),+ (CHECKOUT_METADATA_UPDATED, DISPLAY_LABELS[CHECKOUT_METADATA_UPDATED]),(FULFILLMENT_CREATED, DISPLAY_LABELS[FULFILLMENT_CREATED]),(FULFILLMENT_CANCELED, DISPLAY_LABELS[FULFILLMENT_CANCELED]),(FULFILLMENT_APPROVED, DISPLAY_LABELS[FULFILLMENT_APPROVED]),+ (FULFILLMENT_METADATA_UPDATED, DISPLAY_LABELS[FULFILLMENT_METADATA_UPDATED]),(NOTIFY_USER, DISPLAY_LABELS[NOTIFY_USER]),(PAGE_CREATED, DISPLAY_LABELS[PAGE_CREATED]),(PAGE_UPDATED, DISPLAY_LABELS[PAGE_UPDATED]),@@ -325,18 +360,28 @@ class WebhookEventAsyncType:(SHIPPING_ZONE_CREATED, DISPLAY_LABELS[SHIPPING_ZONE_CREATED]),(SHIPPING_ZONE_UPDATED, DISPLAY_LABELS[SHIPPING_ZONE_UPDATED]),(SHIPPING_ZONE_DELETED, DISPLAY_LABELS[SHIPPING_ZONE_DELETED]),+ (+ SHIPPING_ZONE_METADATA_UPDATED,+ DISPLAY_LABELS[SHIPPING_ZONE_METADATA_UPDATED],+ ),(STAFF_CREATED, DISPLAY_LABELS[STAFF_CREATED]),(STAFF_UPDATED, DISPLAY_LABELS[STAFF_UPDATED]),(STAFF_DELETED, DISPLAY_LABELS[STAFF_DELETED]),(TRANSACTION_ACTION_REQUEST, DISPLAY_LABELS[TRANSACTION_ACTION_REQUEST]),+ (+ TRANSACTION_ITEM_METADATA_UPDATED,+ DISPLAY_LABELS[TRANSACTION_ITEM_METADATA_UPDATED],+ ),(TRANSLATION_CREATED, DISPLAY_LABELS[TRANSLATION_CREATED]),(TRANSLATION_UPDATED, DISPLAY_LABELS[TRANSLATION_UPDATED]),(WAREHOUSE_CREATED, DISPLAY_LABELS[WAREHOUSE_CREATED]),(WAREHOUSE_UPDATED, DISPLAY_LABELS[WAREHOUSE_UPDATED]),(WAREHOUSE_DELETED, DISPLAY_LABELS[WAREHOUSE_DELETED]),+ (WAREHOUSE_METADATA_UPDATED, DISPLAY_LABELS[WAREHOUSE_METADATA_UPDATED]),(VOUCHER_CREATED, DISPLAY_LABELS[VOUCHER_CREATED]),(VOUCHER_UPDATED, DISPLAY_LABELS[VOUCHER_UPDATED]),(VOUCHER_DELETED, DISPLAY_LABELS[VOUCHER_DELETED]),+ (VOUCHER_METADATA_UPDATED, DISPLAY_LABELS[VOUCHER_METADATA_UPDATED]),(OBSERVABILITY, DISPLAY_LABELS[OBSERVABILITY]),]@@ -367,6 +412,7 @@ class WebhookEventAsyncType:GIFT_CARD_UPDATED: GiftcardPermissions.MANAGE_GIFT_CARD,GIFT_CARD_DELETED: GiftcardPermissions.MANAGE_GIFT_CARD,GIFT_CARD_STATUS_CHANGED: GiftcardPermissions.MANAGE_GIFT_CARD,+ GIFT_CARD_METADATA_UPDATED: GiftcardPermissions.MANAGE_GIFT_CARD,MENU_CREATED: MenuPermissions.MANAGE_MENUS,MENU_UPDATED: MenuPermissions.MANAGE_MENUS,MENU_DELETED: MenuPermissions.MANAGE_MENUS,@@ -379,6 +425,7 @@ class WebhookEventAsyncType:ORDER_UPDATED: OrderPermissions.MANAGE_ORDERS,ORDER_CANCELLED: OrderPermissions.MANAGE_ORDERS,ORDER_FULFILLED: OrderPermissions.MANAGE_ORDERS,+ ORDER_METADATA_UPDATED: OrderPermissions.MANAGE_ORDERS,DRAFT_ORDER_CREATED: OrderPermissions.MANAGE_ORDERS,DRAFT_ORDER_DELETED: OrderPermissions.MANAGE_ORDERS,DRAFT_ORDER_UPDATED: OrderPermissions.MANAGE_ORDERS,@@ -392,22 +439,28 @@ class WebhookEventAsyncType:CUSTOMER_CREATED: AccountPermissions.MANAGE_USERS,CUSTOMER_UPDATED: AccountPermissions.MANAGE_USERS,CUSTOMER_DELETED: AccountPermissions.MANAGE_USERS,+ CUSTOMER_METADATA_UPDATED: AccountPermissions.MANAGE_USERS,COLLECTION_CREATED: ProductPermissions.MANAGE_PRODUCTS,COLLECTION_UPDATED: ProductPermissions.MANAGE_PRODUCTS,COLLECTION_DELETED: ProductPermissions.MANAGE_PRODUCTS,+ COLLECTION_METADATA_UPDATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_CREATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_UPDATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_DELETED: ProductPermissions.MANAGE_PRODUCTS,+ PRODUCT_METADATA_UPDATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_VARIANT_CREATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_VARIANT_UPDATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_VARIANT_DELETED: ProductPermissions.MANAGE_PRODUCTS,+ PRODUCT_VARIANT_METADATA_UPDATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_VARIANT_BACK_IN_STOCK: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_VARIANT_OUT_OF_STOCK: ProductPermissions.MANAGE_PRODUCTS,CHECKOUT_CREATED: CheckoutPermissions.MANAGE_CHECKOUTS,CHECKOUT_UPDATED: CheckoutPermissions.MANAGE_CHECKOUTS,+ CHECKOUT_METADATA_UPDATED: CheckoutPermissions.MANAGE_CHECKOUTS,FULFILLMENT_CREATED: OrderPermissions.MANAGE_ORDERS,FULFILLMENT_CANCELED: OrderPermissions.MANAGE_ORDERS,FULFILLMENT_APPROVED: OrderPermissions.MANAGE_ORDERS,+ FULFILLMENT_METADATA_UPDATED: OrderPermissions.MANAGE_ORDERS,NOTIFY_USER: AccountPermissions.MANAGE_USERS,PAGE_CREATED: PagePermissions.MANAGE_PAGES,PAGE_UPDATED: PagePermissions.MANAGE_PAGES,@@ -424,18 +477,22 @@ class WebhookEventAsyncType:SHIPPING_ZONE_CREATED: ShippingPermissions.MANAGE_SHIPPING,SHIPPING_ZONE_UPDATED: ShippingPermissions.MANAGE_SHIPPING,SHIPPING_ZONE_DELETED: ShippingPermissions.MANAGE_SHIPPING,+ SHIPPING_ZONE_METADATA_UPDATED: ShippingPermissions.MANAGE_SHIPPING,STAFF_CREATED: AccountPermissions.MANAGE_STAFF,STAFF_UPDATED: AccountPermissions.MANAGE_STAFF,STAFF_DELETED: AccountPermissions.MANAGE_STAFF,TRANSACTION_ACTION_REQUEST: PaymentPermissions.HANDLE_PAYMENTS,+ TRANSACTION_ITEM_METADATA_UPDATED: PaymentPermissions.HANDLE_PAYMENTS,TRANSLATION_CREATED: SitePermissions.MANAGE_TRANSLATIONS,TRANSLATION_UPDATED: SitePermissions.MANAGE_TRANSLATIONS,VOUCHER_CREATED: DiscountPermissions.MANAGE_DISCOUNTS,VOUCHER_UPDATED: DiscountPermissions.MANAGE_DISCOUNTS,VOUCHER_DELETED: DiscountPermissions.MANAGE_DISCOUNTS,+ VOUCHER_METADATA_UPDATED: DiscountPermissions.MANAGE_DISCOUNTS,WAREHOUSE_CREATED: ProductPermissions.MANAGE_PRODUCTS,WAREHOUSE_UPDATED: ProductPermissions.MANAGE_PRODUCTS,WAREHOUSE_DELETED: ProductPermissions.MANAGE_PRODUCTS,+ WAREHOUSE_METADATA_UPDATED: ProductPermissions.MANAGE_PRODUCTS,OBSERVABILITY: AppPermission.MANAGE_OBSERVABILITY,}diff --git a/saleor/webhook/payload_serializers.py b/saleor/webhook/payload_serializers.pyindex 2f5e4c93ab..b2686993b5 100644--- a/saleor/webhook/payload_serializers.py+++ b/saleor/webhook/payload_serializers.py@@ -42,12 +42,14 @@ class PayloadSerializer(JSONSerializer):self.extra_dict_data = {}self.obj_id_name = "id"self.pk_field_name = "id"+ self.dump_type_name = Truedef serialize(self, queryset, **options):self.additional_fields = options.pop("additional_fields", {})self.extra_dict_data = options.pop("extra_dict_data", {})self.obj_id_name = options.pop("obj_id_name", "id")self.pk_field_name = options.pop("pk_field_name", "id")+ self.dump_type_name = options.pop("dump_type_name", True)return super().serialize(queryset,@@ -64,9 +66,11 @@ class PayloadSerializer(JSONSerializer):obj_id = graphene.Node.to_global_id(obj._meta.object_name, getattr(obj, self.pk_field_name))- data = OrderedDict(- [("type", str(obj._meta.object_name)), (self.obj_id_name, obj_id)]- )+ data = {}+ if self.dump_type_name:+ data["type"] = str(obj._meta.object_name)+ data[self.obj_id_name] = obj_id+# Evaluate and add the "additional fields"python_serializer = PythonSerializer(extra_model_fields=self.extra_model_fields)for field_name, (qs, fields) in self.additional_fields.items():diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex 2dffecdf85..215aa34f2b 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -131,6 +131,28 @@ def generate_meta(*, requestor_data: Dict[str, Any], camel_case=False, **kwargs)return meta+@traced_payload_generator+def generate_metadata_updated_payload(+ instance: Any, requestor: Optional["RequestorOrLazyObject"] = None+):+ serializer = PayloadSerializer()++ if isinstance(instance, Checkout):+ pk_field_name = "token"+ else:+ pk_field_name = "id"++ return serializer.serialize(+ [instance],+ fields=[],+ pk_field_name=pk_field_name,+ extra_dict_data={+ "meta": generate_meta(requestor_data=generate_requestor(requestor)),+ },+ dump_type_name=False,+ )++def prepare_order_lines_allocations_payload(line):warehouse_id_quantity_allocated_map = list(line.allocations.values( # type: ignorediff --git a/saleor/webhook/tests/test_webhook_payloads.py b/saleor/webhook/tests/test_webhook_payloads.pyindex df9b431ea7..60310bde30 100644--- a/saleor/webhook/tests/test_webhook_payloads.py+++ b/saleor/webhook/tests/test_webhook_payloads.py@@ -48,6 +48,7 @@ from ..payloads import (generate_invoice_payload,generate_list_gateways_payload,generate_meta,+ generate_metadata_updated_payload,generate_order_payload,generate_order_payload_for_tax_calculation,generate_payment_payload,@@ -474,6 +475,55 @@ def test_generate_fulfillment_lines_payload_deleted_variant(order_with_lines):assert payload["weight"] is None+@freeze_time()+def test_generate_fulfillment_metadata_updated_payload(+ order_with_lines,+ customer_user,+):+ fulfillment = order_with_lines.fulfillments.create(tracking_number="123")++ # when+ payload = json.loads(generate_metadata_updated_payload(fulfillment, customer_user))[+ 0+ ]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Fulfillment", fulfillment.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }+++@freeze_time()+def test_generate_gift_card_metadata_updated_payload(+ gift_card,+ customer_user,+):+ # when+ payload = json.loads(generate_metadata_updated_payload(gift_card, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("GiftCard", gift_card.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }+++@freeze_time()+def test_generate_voucher_metadata_updated_payload(+ voucher,+ customer_user,+):+ # when+ payload = json.loads(generate_metadata_updated_payload(voucher, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Voucher", voucher.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_order_lines_have_all_required_fields(mocked_fetch_order, order, order_line_with_one_allocation):@@ -670,6 +720,23 @@ def test_order_line_without_sku_still_has_id(order, order_line_with_one_allocatiassert line_payload["product_variant_id"] == line.product_variant_id+@freeze_time()+def test_generate_order_metadata_updated_payload(+ order_for_payload,+ customer_user,+):+ order = order_for_payload++ # when+ payload = json.loads(generate_metadata_updated_payload(order, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Order", order.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_collection_payload(collection):payload = json.loads(generate_collection_payload(collection))expected_payload = [@@ -693,6 +760,40 @@ def test_generate_collection_payload(collection):assert payload == expected_payload+@freeze_time()+def test_generate_shipping_zone_metadata_updated_payload(+ shipping_zone,+ customer_user,+):+ # when+ payload = json.loads(+ generate_metadata_updated_payload(shipping_zone, customer_user)+ )[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("ShippingZone", shipping_zone.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }+++@freeze_time()+def test_generate_collection_metadata_updated_payload(+ collection,+ customer_user,+):+ # when+ payload = json.loads(generate_metadata_updated_payload(collection, customer_user))[+ 0+ ]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Collection", collection.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_base_product_variant_payload(product_with_two_variants):stocks_to_serialize = [variant.stocks.first() for variant in product_with_two_variants.variants.all()@@ -744,6 +845,23 @@ def test_generate_base_product_variant_payload(product_with_two_variants):assert payload == expected_payload+@freeze_time()+def test_generate_product_metadata_updated_payload(+ product_with_variant_with_two_attributes,+ customer_user,+):+ product = product_with_variant_with_two_attributes++ # when+ payload = json.loads(generate_metadata_updated_payload(product, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Product", product.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_product_variant_payload(product_with_variant_with_two_attributes,product_with_images,@@ -880,6 +998,23 @@ def test_generate_product_variant_deleted_payload(assert len(payload.keys()) == len(payload_fields)+@freeze_time()+def test_generate_product_variant_metadata_updated_payload(+ product_with_variant_with_two_attributes,+ customer_user,+):+ variant = product_with_variant_with_two_attributes.variants.first()++ # when+ payload = json.loads(generate_metadata_updated_payload(variant, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("ProductVariant", variant.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++@freeze_time("1914-06-28 10:50")def test_generate_invoice_payload(fulfilled_order):fulfilled_order.origin = OrderOrigin.CHECKOUT@@ -1043,6 +1178,22 @@ def test_generate_payment_with_transactions_payload(dummy_webhook_app_payment_daassert payload == json.dumps(expected_payload, cls=CustomJsonEncoder)+@freeze_time()+def test_generate_transaction_item_metadata_updated_payload(+ transaction_item, customer_user+):+ # when+ payload = json.loads(+ generate_metadata_updated_payload(transaction_item, customer_user)+ )[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("TransactionItem", transaction_item.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_checkout_lines_payload(checkout_with_single_item):payload = json.loads(generate_checkout_payload(checkout_with_single_item))[0]assert payload.get("lines")@@ -1070,6 +1221,23 @@ def test_generate_checkout_lines_payload_custom_price(checkout_with_single_item)assert line_data["base_price"] == str(price_override)+@freeze_time()+def test_generate_checkout_metadata_updated_payload(+ checkout_with_single_item,+ customer_user,+):+ checkout = checkout_with_single_item++ # when+ payload = json.loads(generate_metadata_updated_payload(checkout, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Checkout", checkout.token),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_product_translation_payload(product_translation_fr):payload = generate_translation_payload(product_translation_fr)data = json.loads(payload)@@ -1278,6 +1446,22 @@ def test_generate_customer_payload(customer_user, address_other_country, addressassert payload == expected_payload+@freeze_time()+def test_generate_customer_metadata_updated_payload(+ customer_user,+):+ # when+ payload = json.loads(+ generate_metadata_updated_payload(customer_user, customer_user)+ )[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("User", customer_user.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }++def test_generate_collection_point_payload(order_with_lines_for_cc):payload = json.loads(generate_order_payload(order_with_lines_for_cc))[0]@@ -1931,3 +2115,18 @@ def test_generate_transaction_action_request_payload_for_checkout("version": __version__,},}+++@freeze_time()+def test_generate_warehouse_metadata_updated_payload(+ warehouse,+ customer_user,+):+ # when+ payload = json.loads(generate_metadata_updated_payload(warehouse, customer_user))[0]++ # then+ assert payload == {+ "id": graphene.Node.to_global_id("Warehouse", warehouse.id),+ "meta": generate_meta(requestor_data=generate_requestor(customer_user)),+ }