The product designer already checks resolution, contrast, safe margin, overlap and the number of print colours by itself. If your production has further rules, such as “a logo must be at least 15 mm wide” or “no text below 6 mm on hot foil”, you add your own checks: in the browser with JavaScript or on your server via a webhook.
| Way | What for | Limit |
|---|---|---|
In the browser (registerDesignCheck) |
An immediate note at the field while your customer designs | Can be bypassed with a crafted request |
| On the server (webhook) | Binding rules that no order may get around | Only works if your shop plugin enforces the price check |
For a rule that has to hold, use the webhook. Ideally you combine both: the browser shows the note straight away, the server makes sure.
Check in the browser
You register a check through the JavaScript API:
Configento.registerDesignCheck('logo-min-width', (ctx) =>
ctx.placement && ctx.placement.widthMm < 15
? { level: 'block', message: 'The logo must be at least 15 mm wide.' }
: null,
{ appliesTo: ['logo'] });
- The name consists of lower-case letters, digits and hyphens.
appliesTolists the Internal names (ID) of the characteristics the check applies to. WithoutappliesToit runs for every custom text and every custom image.registerDesignCheckreturns a function that unregisters the check again.
If your script runs before configento.js has loaded, define the checks in advance:
window.ConfigentoDesignChecks = {
'logo-min-width': [check, { appliesTo: ['logo'] }],
};
What the check receives
The check runs on every change and receives an object ctx:
| Field | Content |
|---|---|
characteristic |
id, key (internal name), type (customtext or customimage), title |
locale |
Language of the configurator, e.g. en_GB |
zone |
widthMm, heightMm, plus background and safeMm if set |
box |
The area the text or picture actually covers, in mm from the top left; null if nothing is visible |
values |
The other characteristics by internal name, as formulas see them: a select gives its value, numbers stay numbers |
text, lines |
For a custom text: the text and its lines |
design |
For a custom text: font, sizeMm, drawnSizeMm, color, colorName, align, valign and finish if a finish applies |
image |
For a custom image: file, type, width, height in pixels, vector for SVG |
placement |
For a custom image: widthMm, heightMm, dpi, rotation, flipX, centerXMm, centerYMm |
What the check answers
null: everything is fine.{ level: 'warn', message: '…' }: the note appears at the field, ordering is still possible.{ level: 'block', message: '…' }: the note appears at the field, and the configurator holds back the cart.- A list of such results if several things don't fit.
You style the note with the class .cfg-design__check; data-configento-level says whether it is a warning or a block, and data-configento-check names your check. See Customise the design. If a check throws an error, the configurator ignores it and writes the error to the browser console.
Check on your server
With a webhook, your server checks every design before it goes into the cart. That way the rule holds even if someone bypasses the browser.
Setting it up
- In the admin, open Settings → API and there Design check webhook.
- Enter the Webhook URL. Only
httpsto a public address is allowed. - configento.app generates a Signing secret (
dcw_…). Store it on your server. New secret replaces it. - Click Send test call. If your server answers, “The webhook answered.” appears.
- Decide whether Refuse the cart when the webhook does not answer should apply (see below).
The request
When a configuration is added to the cart, configento.app recalculates the price and sends all visible, filled custom texts and pictures to your URL via POST:
{
"event": "design_check",
"component_id": "10000021",
"locale": "en_GB",
"fields": [ { "characteristic": { "key": "logo", "type": "customimage" }, "placement": { "widthMm": 12.4, "dpi": 310 } } ]
}
Each element in fields has the same structure as ctx in the browser (shown shortened). Only box is always null on the server.
The headers:
| Header | Content |
|---|---|
X-Configento-Event |
design_check, test for the test call (then fields is empty) |
X-Configento-Timestamp |
Time in Unix seconds |
X-Configento-Signature |
sha256= and the hex value of HMAC-SHA256 with your secret over timestamp + . + raw request body |
Verify the signature before you trust the request, e.g. in Node.js:
const crypto = require('crypto');
const expected = 'sha256=' + crypto.createHmac('sha256', process.env.CONFIGENTO_DCW_SECRET)
.update(req.headers['x-configento-timestamp'] + '.' + rawBody).digest('hex');
const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.headers['x-configento-signature'] || ''));
Also discard requests whose timestamp is more than a few minutes old.
The answer
Your server answers with status 2xx and:
{ "findings": [ { "field": "logo", "level": "block", "message": "The logo must be at least 15 mm wide." } ] }
field is the internal name of the characteristic. An empty list means everything is fine.
| Result | Effect |
|---|---|
A finding with block |
The price check refuses (error design_check_failed with your message). The configuration does not go into the cart. |
Only findings with warn |
The price applies; the notes come along as design_checks. |
| No usable answer | The cart goes through. With Refuse the cart when the webhook does not answer, the price check refuses instead (design_check_unavailable). |
Your server has 2 seconds; configento.app does not follow redirects. The result is valid together with the price for 5 minutes, and an identical configuration does not ask again during that time.
Requirement in the shop
The webhook runs in the price check. If it blocks, the configuration does not go into the cart and your customer sees your message there, from these plugin versions on:
| Shop | Plugin from | Block applies |
|---|---|---|
| Shopware | 5.3.9 | always; the plugin always checks configurations with the product designer bindingly |
| Magento | 5.1.14 | with the price check set to Enforce; with Shadow the configuration goes through and the block only ends up in the log |
| PrestaShop | 0.6.10 | always |
| WooCommerce/WordPress | 0.6.5 | always |
With older plugin versions the block applies as well, but your customer only sees the general message that the configuration is no longer valid or the price could not be confirmed.
So also show your message through a check in the browser; then your customer sees it while designing.
Troubleshooting
- The browser check has no effect: Is the internal name in
appliesTocorrect? Is the script loaded afterconfigento.js, or do you usewindow.ConfigentoDesignChecks? Errors of the check are in the browser console. - “The webhook did not answer usably”: Your server does not answer within 2 seconds, redirects, answers without 2xx or without valid JSON.
- The block has no effect in the shop: In Magento the price check is not set to Enforce. Your customer only sees a general message: The plugin is older than the versions above.
- The signature does not match: Calculate over the unchanged raw request body, not over re-encoded JSON, and check whether you stored the new secret after New secret.