> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Package: serviceFees # Namespace: rules # Webhook link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/service-fees/rules/rule-updated.md ## Introduction # Webhook Permissions Scopes IDs: --- ## REST API ### Schema ``` Webhook: Rule Updated Description: Event body: - name: id | type: string | description: Unique event ID. Allows clients to ignore duplicate events. - name: entityFqdn | type: string | description: Fully qualified domain name of the entity associated with the event. - name: slug | type: string | description: Event name. - name: entityId | type: string | description: ID of the entity associated with the event. - name: eventTime | type: string (date-time) | description: Event timestamp. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application such as GDPR. - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: updatedEvent | type: object | description: Updated event details. - name: currentEntity | type: Rule | description: The entity after the update. - ONE-OF: - ONE-OF: - name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value. - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. - name: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total. - ONE-OF: - ONE-OF: - name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - ONE-OF: - name: number | type: Number | description: Contains a numeric value and an operation. Required if `expectedFieldType` is `NUMBER`. - name: value | type: number | description: Numeric value to compare with the value of the specified field. - name: operation | type: Operation | description: Operation to use. - enum: - EQ: Equal to. - LT: Strictly less than. - LE: Less than or equal to. - GT: Strictly greater than. - GE: Greater than or equal to. - name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met. Required if `expectedFieldType` is `LIST`. - name: values | type: array | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met. - name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`. - name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`). - enum: - UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type - NUMBER: Represents a number value. - STRING: Represents a string value. - name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - ONE-OF: - name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - ONE-OF: - name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions. - enum: - AND: The condition is true if both the left and right sides are true. - OR: The condition is true if either the left or right side is true. - ONE-OF: - name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100]. - name: taxGroupId | type: string | description: Tax group GUID. Internal only. - name: id | type: string | description: Rule GUID. - name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule. - name: name | type: string | description: Rule name. - name: createdDate | type: string | description: Date and time the rule was created. - name: updatedDate | type: string | description: Date and time the rule was updated. - name: conditionType | type: ConditionType | description: Specifies the type of condition. - enum: - UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified. - CONDITION: Indicates that the Rule has a single Condition. - CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree. - name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated. - name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule. - name: appId | type: string | description: Defines the app that the rule is connected to. - name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation. - enum: - HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`. - HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`. - name: extendedFields | type: ExtendedFields | description: Data Extensions - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules. - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors. - name: tagIds | type: array | description: List of tag GUIDs - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors. - name: modifiedFields | type: Map | description: Fields that were updated and their values before the update. ``` ### Examples ```curl { "id":"88ff68de-2ad5-47c8-8872-c2479408bc5d", "entityFqdn":"wix.service.fees.v1.rule", "slug":"updated", "entityId":"3799059d-260f-4f7f-b515-4fe3988a5540", "updatedEvent":{ "currentEntity":"{\"id\":\"3799059d-260f-4f7f-b515-4fe3988a5540\",\"name\":\"Rule Name 2\",\"createdDate\":\"2024-01-28T14:16:28.525Z\",\"updatedDate\":\"2024-01-28T14:25:47.220Z\",\"amount\":{\"value\":\"10\",\"currency\":\"EUR\"},\"fixedFee\":{\"value\":\"10\",\"currency\":\"EUR\"},\"condition\":{\"path\":\"shippingInfo.logistics.type\",\"orderFieldPath\":\"shippingInfo.logistics.type\",\"expectedType\":{\"value\":\"STRING\"},\"expectedFieldType\":\"STRING\",\"list\":{\"values\":[\"DELIVERY\"]}},\"conditionsType\":\"CONDITION\",\"conditionType\":\"CONDITION\",\"conditionOptions\":{\"path\":\"shippingInfo.logistics.type\",\"orderFieldPath\":\"shippingInfo.logistics.type\",\"expectedType\":{\"value\":\"STRING\"},\"expectedFieldType\":\"STRING\",\"list\":{\"values\":[\"DELIVERY\"]}},\"enabled\":true,\"revision\":\"2\",\"appId\":\"9a5d83fd-8570-482e-81ab-cfa88942ee60\",\"roundingStrategy\":\"UNKNOWN_ROUNDING_STRATEGY\"}" }, "eventTime":"2024-01-28T14:25:47.328707384Z", "triggeredByAnonymizeRequest":false, "entityEventSequence":"2" } ``` --- ## JavaScript SDK ### Schema ``` Webhook: onRuleUpdated Description: Payload: RuleUpdatedEnvelope - name: entity | type: Rule | description: none - ONE-OF: - ONE-OF: - name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value. - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. - name: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total. - ONE-OF: - ONE-OF: - name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - ONE-OF: - name: number | type: Number | description: Contains a numeric value and an operation. Required if `expectedFieldType` is `NUMBER`. - name: value | type: number | description: Numeric value to compare with the value of the specified field. - name: operation | type: Operation | description: Operation to use. - enum: - EQ: Equal to. - LT: Strictly less than. - LE: Less than or equal to. - GT: Strictly greater than. - GE: Greater than or equal to. - name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met. Required if `expectedFieldType` is `LIST`. - name: values | type: array | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met. - name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`. - name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`). - enum: - UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type - NUMBER: Represents a number value. - STRING: Represents a string value. - name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - ONE-OF: - name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - ONE-OF: - name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order. - name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order. - name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions. - enum: - AND: The condition is true if both the left and right sides are true. - OR: The condition is true if either the left or right side is true. - ONE-OF: - name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100]. - name: taxGroupId | type: string | description: Tax group GUID. Internal only. - name: _id | type: string | description: Rule GUID. - name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule. - name: name | type: string | description: Rule name. - name: _createdDate | type: Date | description: Date and time the rule was created. - name: _updatedDate | type: Date | description: Date and time the rule was updated. - name: conditionType | type: ConditionType | description: Specifies the type of condition. - enum: - UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified. - CONDITION: Indicates that the Rule has a single Condition. - CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree. - name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated. - name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule. - name: appId | type: string | description: Defines the app that the rule is connected to. - name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation. - enum: - HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`. - HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`. - name: extendedFields | type: ExtendedFields | description: Data Extensions - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules. - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors. - name: tagIds | type: array | description: List of tag GUIDs - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors. - name: modifiedFields | type: Map | description: Fields that were updated and their values before the update. - ONE-OF: - name: nullValue | type: | description: - name: numberValue | type: number | description: - name: stringValue | type: string | description: - name: boolValue | type: boolean | description: - name: structValue | type: object | description: - name: listValue | type: ListValue | description: - name: values | type: array | description: - name: metadata | type: EventMetadata | description: none - name: instanceId | type: string | description: App instance GUID. - name: eventType | type: string | description: Event type. - name: identity | type: IdentificationData | description: The identification type and identity data. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: identityType | type: WebhookIdentityType | description: - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP - name: accountInfo | type: AccountInfo | description: Details related to the account - name: accountId | type: string | description: GUID of the Wix account associated with the event. - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account. - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site. - name: _id | type: string | description: Event GUID. With this GUID you can easily spot duplicated events and ignore them. - name: entityFqdn | type: string | description: Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`. - name: slug | type: string | description: Event action name, placed at the top level to make it easier for users to dispatch messages. For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`. - name: entityId | type: string | description: GUID of the entity associated with the event. - name: eventTime | type: Date | description: Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application (for example, GDPR). - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: entityEventSequence | type: string | description: A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at 16:00 and then again at 16:01, the second update will always have a higher sequence number. You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it. ``` ### Examples ```javascript import { serviceFees } from '@wix/restaurants'; serviceFees.onRuleUpdated((event) => { // handle your event here }); ``` ```javascript import { createClient, AppStrategy } from '@wix/sdk'; import { serviceFees } from '@wix/restaurants'; const wixClient = createClient({ auth: AppStrategy({ appId: 'MY-APP-ID', publicKey: 'YOUR_APP_PUBLIC_KEY', }), modules: { serviceFees, }, }); wixClient.serviceFees.onRuleUpdated((event) => { // handle your event here }); ``` ---