You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/webhooks/responses.md
+154-8Lines changed: 154 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -7,19 +7,28 @@ keywords:
7
7
8
8
# Webhook responses and logging
9
9
10
-
Currently, Adobe Commerce webhooks only support two responses: `success` and `exception`. Responses that require additional processing, such as parsing the results of a GET response, are not supported.
10
+
Currently, Adobe Commerce webhooks only support responses in JSON format. The response may be a single operation or the array of operations which will be executed consequently.
11
+
Each operation must contain some required fields based on the desired operation.
11
12
12
13
Exceptions and notices are logged in the `<installation_directory>/var/log/system.log` file.
13
14
14
15
## Responses
15
16
16
-
The endpoint is expected to return a `200` response and a JSON object that indicates the result of the operation. The object can contain the following fields:
17
+
The endpoint is expected to return a `200` response and a JSON object or array of objects that indicates the result of the operation. The object can contain the list of fields based on the operation (`op`) which should be performed.
17
18
18
-
Field | Description
19
+
At the moment Adobe Commerce webhooks support 5 different operations:
20
+
21
+
operation | Description
19
22
--- | ---
20
-
`op` | The status of the operation: either `success` or `exception`.
21
-
`class` | If the `op` status is `exception`, optionally specifies the exception class. If `class` is not set, the `\Magento\Framework\Exception\LocalizedException` will be thrown.
22
-
`message` | If the `op` status is `exception`, optionally specifies the exception message. If this field is not explicitly set, then the message defined in the `fallbackErrorMessage` configuration field will be returned. If `fallbackErrorMessage` is not set, the system default error message will be shown.
23
+
`success` | the process that triggered the original event continues without any changes.
24
+
`exception` | causes Commerce to terminate the process that triggered the original event
25
+
`add` | updates the arguments in the original events by adding data described in the operation
26
+
`replace` | replaces the arguments values in the original events based based on the response
27
+
`remove` | removes values or nodes from the arguments in the original event by provided path
28
+
29
+
### Success operation
30
+
31
+
The `success` operation is returned in cases when changes are not needed and the process that triggered the original event continues without any changes.
23
32
24
33
The response of a successful request is as follows:
25
34
@@ -29,7 +38,15 @@ The response of a successful request is as follows:
29
38
}
30
39
```
31
40
32
-
The process that triggered the original event continues without any changes.
41
+
### Exception operation
42
+
43
+
The `exception` operation causes Commerce to terminate the process that triggered the original event. The exception is logged in `<installation_directory>/var/log/system.log`.
44
+
45
+
Field | Type | Description
46
+
--- | --- | ---
47
+
`op` | required | `exception`
48
+
`class` | optional | specifies the exception class. If `class` is not set, the `\Magento\Framework\Exception\LocalizedException` will be thrown.
49
+
`message` | optional | specifies the exception message. If this field is not explicitly set, then the message defined in the `fallbackErrorMessage` configuration field will be returned. If `fallbackErrorMessage` is not set, the system default error message will be shown.
33
50
34
51
If an error occurs, the response is similar to the following:
35
52
@@ -41,7 +58,136 @@ If an error occurs, the response is similar to the following:
41
58
}
42
59
```
43
60
44
-
The `exception` operation causes Commerce to terminate the process that triggered the original event. The exception is logged in `<installation_directory>/var/log/system.log`.
61
+
### Add operation
62
+
63
+
The `add` operation causes Commerce to add provided `value` to the provided `path` to the triggered event arguments
64
+
65
+
Field | Type | Description
66
+
--- |----------| ---
67
+
`op` | required | `add`
68
+
`path` | required | specifies the path at which the `value` should be added to the triggered event arguments
69
+
`value` | required | specifies the value that should be added, can be as a single value or in the array format
70
+
`instance` | optional | specifies the DataObject class name which should be created based on `value` and added to the provided `path`. Used for the cases when the object should be added in provided path.
71
+
72
+
For example, we want to add a new shipping method to the triggered event result payload:
73
+
The result is an array of `Magento\Quote\Model\Cart\ShippingMethod` objects:
Based on this operation the new instance of `Magento\Quote\Model\Cart\ShippingMethodInterface` will be created and added to the result array of shipping methods.
0 commit comments