Skip to content

Build a fulfilment provider

When a buyer pays for a digital product, Commerce records an entitlement: the fact that this person may have this thing. A fulfilment provider is a service that makes that true somewhere else, such as issuing a licence key, creating an account or unlocking a course. You host the service. A merchant adds it to Commerce by pasting its address, and Commerce calls it, signed, when an entitlement is granted or revoked.

A provider holds no ebitex credential and runs no code inside ebitex. It is told only what the merchant approves.

Three endpoints under one HTTPS base address:

Call Purpose
GET {base}/manifest Says who the provider is, its version, the settings it takes and the permissions it needs.
POST {base}/grant The buyer is entitled: make it so.
POST {base}/revoke The entitlement ended (refunded, expired or taken back): undo it.

The address must be HTTPS and reachable from the public internet. Commerce follows no redirect and will not call a private address.

{
"protocol": 1,
"key": "acme-licences",
"name": "Acme licences",
"description": "Issues a licence key and emails it to the buyer.",
"version": "1.2.0",
"settings": [
{ "key": "plan", "label": "Plan", "kind": "text", "required": true, "help": "Which plan to issue." }
],
"account": [
{ "key": "api-key", "label": "Your Acme API key", "kind": "secret", "required": true }
],
"permissions": [
{ "permission": "contact.email", "required": true, "reason": "To email the licence key." },
{ "permission": "contact.name", "required": false }
]
}
  • key is lowercase letters, digits and hyphens, 3 to 64 characters, and is what a product variant names. It does not change.
  • version is major.minor.patch. Commerce only compares versions: a higher one is an upgrade the merchant approves.
  • settings are asked for once per product variant (text or url). account settings are asked for once when the merchant registers you (text, url or secret); a secret is stored protected and is never shown again. Both are sent to you together in settings on every call.

Every call carries the entitlement itself: the entitlement id, an idempotency key, the organization and store ids, the SKU, the Audience person id, whether it is a test, your settings and the end time. Anything beyond that is a permission you declare and the merchant approves:

Permission You receive
contact.email The buyer’s email address, in contact.email.
contact.name The buyer’s name, in contact.name.
order.summary The order number, currency and total, in order.
address.delivery The delivery address (country, region, postal code), in address.delivery.
address.billing The billing address, in address.billing.

Rules the merchant and you can rely on:

  • You are sent exactly what was approved, and nothing else. A permission you did not declare is never sent, whatever you ask later.
  • A required permission that is not approved rejects the delivery, not your provider. Commerce does not call you; the entitlement shows a failed delivery that names the missing permission, and the merchant can approve it and try again. Other entitlements carry on.
  • An optional permission that is not approved is simply absent from the body. Handle a missing field.
  • A change of permissions is a new version. Publish it with a higher version. Commerce re-reads your manifest when the merchant presses Check for updates and once a day, shows the merchant what is new, and keeps serving on the approved version until they approve. Nothing is switched off.

Both grant and revoke receive the same JSON body:

{
"protocol": 1,
"action": "grant",
"idempotencyKey": "entitlement:6f1c2b0e9a8d4c37b1e5a2d90c7f4b61:grant",
"entitlementId": "6f1c2b0e-9a8d-4c37-b1e5-a2d90c7f4b61",
"organizationId": "08b27ef8-fb84-4800-99f1-40302e68830e",
"storeId": "941f7df5-d1d9-4ea2-a942-3629603ea099",
"sku": "PRO-LICENCE",
"personId": "db0ee23a-6229-4014-8534-d4e7c46c9f7e",
"test": false,
"endsAt": null,
"settings": { "plan": "pro", "api-key": "…" },
"contact": { "email": "ada@example.com" }
}

Answer with a 2xx and a JSON body:

outcome Meaning
done It is done: granted (or revoked). Commerce marks the entitlement delivered.
retry Not now. Commerce asks again, with growing delays.
failed Asking again will not change it. The merchant sees your message and can try again once they have fixed something.

Add a short code and, for failed or retry, a message the merchant can read (at most 200 characters; never a key or a response body). A 429, any 5xx, a timeout or a network failure is treated as retry. Any other status is a failed with the status as its code.

Be idempotent on idempotencyKey. The same grant can arrive more than once (a retry, a replay); doing it twice must have the effect of once. A test-mode entitlement has test: true: change nothing real for it.

Each call carries an X-Ebitex-Signature header made exactly as the organization webhooks’ is: an HMAC-SHA256 of {timestamp}.{body} under the signing secret, which the merchant is shown once when they register you. Verify it against the raw bytes you received, reject a timestamp older than five minutes, and compare in constant time. The scheme is described in full in Webhooks.

The header may also name the key it was signed under, as v1,t=<seconds>,k=<key id>,s=<hex>. The key id is not part of what is signed. If you hold one secret you can ignore it; if you hold two (see below) it tells you which to verify with.

To change your secret without a failed call, the merchant starts a rotation in Hub: a new secret is made and shown once, while calls keep being signed with the current one. Give your service the new secret and the key id Hub shows with it, and have it accept either. When it does, the merchant switches: from the next call, signatures use the new secret and carry that key id. Then your service can drop the old one. A secret you generate is never changed without this overlap.

A single file of Node, with no dependencies. It serves the manifest, verifies the signature, is idempotent, and answers done.

// example:fulfilment-provider
import { createServer } from 'node:http'
import { createHmac, timingSafeEqual } from 'node:crypto'
export const MANIFEST = {
protocol: 1,
key: 'example-licences',
name: 'Example licences',
description: 'Pretends to issue a licence key.',
version: '1.0.0',
settings: [{ key: 'plan', label: 'Plan', kind: 'text' }],
account: [],
permissions: [{ permission: 'contact.email', required: true, reason: 'To email the licence key.' }],
}
/** True when `header` (`v1,t=<unix seconds>[,k=<key id>],s=<hex>`) is a fresh, correct signature of `rawBody`. */
export function verify(rawBody, header, secret, now = Date.now()) {
const match = /^v1,t=(\d+)(?:,k=[A-Za-z0-9._-]{1,32})?,s=([0-9a-f]{64})$/.exec(header ?? '')
if (!match) return false
const [, t, s] = match
if (Math.abs(now / 1000 - Number(t)) > 300) return false
const expected = createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest()
const given = Buffer.from(s, 'hex')
return given.length === expected.length && timingSafeEqual(given, expected)
}
export function createProvider(secret) {
const answered = new Map() // idempotencyKey -> answer; keep this in a database in a real provider
return createServer((request, response) => {
const send = (status, body) => {
response.writeHead(status, { 'Content-Type': 'application/json' })
response.end(JSON.stringify(body))
}
if (request.method === 'GET' && request.url?.endsWith('/manifest')) return send(200, MANIFEST)
const chunks = []
request.on('data', (chunk) => chunks.push(chunk))
request.on('end', () => {
const raw = Buffer.concat(chunks)
if (!verify(raw, request.headers['x-ebitex-signature'], secret)) return send(401, { error: 'bad_signature' })
const call = JSON.parse(raw.toString('utf8'))
if (call.test) return send(200, { outcome: 'done', code: 'test' }) // change nothing real for a test
if (answered.has(call.idempotencyKey)) return send(200, answered.get(call.idempotencyKey))
if (!call.contact?.email) return send(200, { outcome: 'failed', code: 'no_email', message: 'No email address was approved.' })
// Do the real work here: issue a licence for call.settings.plan and email call.contact.email.
const answer = { outcome: 'done', code: call.action }
answered.set(call.idempotencyKey, answer)
send(200, answer)
})
})
}

In Hub, open Plugins and choose Add by address. Paste your base address, review the permissions you asked for, approve the optional ones you want, fill in any account settings and add it. Hub shows the signing secret once. Then use Send a test: it makes the same signed call a real entitlement would, with test: true, so you can see it arrive and see exactly which fields were sent.

Open the provider in Hub to review a newer version, send a test, turn it off or remove it. A provider something still uses cannot be turned off or removed until that is changed. On a product, choose your provider for a digital variant and fill in its settings.

Providers that ebitex hosts itself are registered the same way, from an address on ebitex’s own plugin host. They follow the same protocol and are limited by the same permissions as yours. The only difference is that ebitex approves what they declare, so the merchant is not asked to.

  • A call has ten seconds to answer. A slower answer is a retry.
  • Commerce tries again with growing delays until the entitlement is delivered or the merchant stops it; a failed answer waits for the merchant instead.
  • If your address stops being reachable, the entitlement shows why and the merchant can try again once it is back.
  • The manifest is at most 16 KB. Keys, labels and descriptions have the lengths shown above; a manifest that breaks them is refused when the merchant adds it, with the reason.