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
+29-29Lines changed: 29 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ keywords:
7
7
8
8
# Webhook responses and logging
9
9
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.
10
+
Currently, Adobe Commerce webhooks support responses in JSON format only. The response may be a single operation or an array of operations to be executed afterward.
11
11
Each operation must contain some required fields based on the desired operation.
12
12
13
13
Exceptions and notices are logged in the `<installation_directory>/var/log/system.log` file.
@@ -16,19 +16,19 @@ Exceptions and notices are logged in the `<installation_directory>/var/log/syste
16
16
17
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. Each operation object can contain the list of fields based on the operation (`op`) which should be performed.
18
18
19
-
At the moment Adobe Commerce webhooks support 5 different operations:
19
+
Adobe Commerce webhooks support the following operations:
20
20
21
-
operation | Description
21
+
Operation | Description
22
22
--- | ---
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
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 event by adding data described in the operation
26
+
`replace` | Replaces argument values in the original event, based on the response.
27
+
`remove` | Removes values or nodes from the arguments in the original event by the provided path
28
28
29
29
### Success operation
30
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.
31
+
The `success` operation is returned when changes are not needed. The process that triggered the original event continues without any changes.
32
32
33
33
The response of a successful request is as follows:
34
34
@@ -44,32 +44,32 @@ The `exception` operation causes Commerce to terminate the process that triggere
44
44
45
45
Field | Type | Description
46
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.
47
+
`op` | Required | Contains `exception`.
48
+
`class` | Optional | Specifies the exception class. If `class` is not set, `\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 returned.
50
50
51
51
If an error occurs, the response is similar to the following:
52
52
53
53
```json
54
54
{
55
55
"op": "exception",
56
56
"class": "Path\\To\\Exception\\Class",
57
-
"message": "The product can not be added to the cart as it is out of the stock"
57
+
"message": "The product cannot be added to the cart because it is out of the stock"
58
58
}
59
59
```
60
60
61
61
### Add operation
62
62
63
-
The `add` operation causes Commerce to add provided `value` to the provided `path` to the triggered event arguments
63
+
The `add` operation causes Commerce to add the provided `value` to the provided `path` to the triggered event arguments
64
64
65
65
Field | Type | Description
66
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.
67
+
`op` | Required | Contains `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 to be added. This can be as a single value or in an array format.
70
+
`instance` | Optional | Specifies the `DataObject` class name to create, based on the `value` and added to the provided `path`. Use this field for cases when the object should be added in provided path.
71
71
72
-
For example, we want to add a new shipping method to the triggered event result payload:
72
+
For example, we want to add a new shipping method to the triggered event result payload.
73
73
The result is an array of `Magento\Quote\Model\Cart\ShippingMethod` objects:
74
74
75
75
```php
@@ -97,7 +97,7 @@ To add a new shipping method to that result, the response from the webhook would
97
97
}
98
98
```
99
99
100
-
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.
100
+
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.
101
101
102
102
```php
103
103
$result = [
@@ -109,16 +109,16 @@ $result = [
109
109
110
110
### Replace operation
111
111
112
-
The `replaces` operation causes Commerce to replace a value in triggered event arguments for the provided `path`
112
+
The `replace` operation causes Commerce to replace a value in triggered event arguments for the provided `path`
113
113
114
114
Field | Type | Description
115
115
--- |----------| ---
116
-
`op` | required | `replace`
117
-
`path` | required | specifies the path at which the value should be replaced with the provided `value`
118
-
`value` | required | specifies the new value that replaces the value by provided `path`, can be as a single or in the array format
119
-
`instance` | optional | specifies the DataObject class name which should be created based on `value` and used as value to replaced by path`path`.
116
+
`op` | Required | Contains `replace`.
117
+
`path` | Required | Specifies the path at which the value should be replaced with the provided `value`.
118
+
`value` | Required | Specifies the replacement value. This can be as a single value or in an array format.
119
+
`instance` | Optional | Specifies the `DataObject` class name to create, based on the `value` and added to the provided`path`.
120
120
121
-
For example, we want to a replace a nested element in the triggered event result payload:
121
+
The following example replaces a nested element in the triggered event result payload:
122
122
123
123
```php
124
124
$result = [
@@ -158,10 +158,10 @@ The `remove` operation causes Commerce to remove a value or node in triggered ev
158
158
159
159
Field | Type | Description
160
160
--- |----------| ---
161
-
`op` | required | `remove`
162
-
`path` | required | specifies the path at which the value should be removed
161
+
`op` | Required | Contains `remove`.
162
+
`path` | Required | Specifies the path at which the value should be removed.
163
163
164
-
For example, we want to a remove en element `key2` from the triggered event result payload:
164
+
The following example removes element `key2` from the triggered event result payload:
0 commit comments