@@ -88,6 +88,27 @@ To verify the signature in the App Builder action, set the `raw-http` annotation
88
88
raw-http : true
89
89
` ` `
90
90
91
+ Store the public key in the ` PUBLIC_KEY` parameter in the `.env` file using the same format as provided in the Adobe Commerce Admin:
92
+
93
+ ` ` ` env
94
+ # Other secrets and configuration
95
+ # ...............................
96
+
97
+ PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
98
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtglXYVz5pVn3HDluGG5T
99
+ t9coO5NKSWjx3xCDMHVa3CEqVM76PKg8UJH9fQOA57xoNv7Llc916pF0UswtudQh
100
+ Fyg+WQCFFadqGZOyL2nUKI9xWBiUi4dN8+9yMd3TE1fszVUBnk/XdLKNDQn4O6ic
101
+ doQZi5arrjNjInkimtcT2jPXs34p9G9P5CvCubPUmbGsWDgwo5an9LEX/nJfnCdZ
102
+ R10XPkRWzEM7o1OGzf7CYo06Xl+msGVM02Er265PsMAWB11cWwKmyg6dLPa8q+Qh
103
+ KNXZiEMvdVusV8aA6EkCZYFdWSBXv+jltn6NnY5qvYcuQ3SujQ9xKEANjeMWcW90
104
+ PwIDAQAB
105
+ -----END PUBLIC KEY-----"
106
+ ` ` `
107
+
108
+ **Note:** Do not commit the `.env` file to version control.
109
+
110
+ [App Builder Configuration Files](https://developer.adobe.com/app-builder/docs/guides/configuration/#env) describes `.env` file usage in detail.
111
+
91
112
The following code example below shows how the signature can be verified in the App Builder action :
92
113
93
114
` ` ` javascript
@@ -109,9 +130,20 @@ async function main (params) {
109
130
if (isSignatureValid) {
110
131
logger.info('The signature is valid.');
111
132
// Here will be performed real action logic
112
- operations.push({
113
- op : ' success'
114
- });
133
+ // payload is base64 encoded, so we need to decode it before using
134
+ const payload = JSON.parse(atob(params.__ow_body))
135
+
136
+ // a simple validation if the provided postcode from Commerce webhook is less than 50000
137
+ if (payload.address.postcode > 50000) {
138
+ operations.push({
139
+ op: 'exception',
140
+ message: 'The postcode is not allowed. Provided postcode: ' + payload.address.postcode
141
+ });
142
+ } else {
143
+ operations.push({
144
+ op: 'success'
145
+ });
146
+ }
115
147
} else {
116
148
logger.info('The signature is invalid.');
117
149
operations.push({
0 commit comments