Delivery plugins
Generate license keys, files or instructions for each order line when an order is paid.
Pick the products a delivery plugin handles in its products setting. When an order with one of them is paid, the
dynamic_delivery fulfillment step calls deliver once per line. A failure is retried with the step’s backoff and
the order shows “needs attention” if it never succeeds.
{
"name": "License generator", "version": "1.0.0", "kind": "delivery",
"permissions": { "http": [], "kv": true },
"settings": [
{ "key": "prefix", "label": "Key prefix", "type": "text" },
{ "key": "products", "label": "Products", "type": "products", "required": true }
]
}
function plugin.deliver(ctx, input)
local keys = {}
for i = 1, input.line.quantity do
keys[i] = (ctx.settings.prefix or "KEY") .. "-" .. string.upper(crypto.random_hex(8))
end
kv.incr("issued", #keys)
return {
keys = keys,
message = "Activate it from Settings, then Licenses.",
file = { name = "license.txt", content = table.concat(keys, "\n") },
}
end
input: order (id, number, currency, buyerEmail), line (productId, productName, variantName,
quantity, unitMinor) and customFields (the buyer’s checkout answers, without password fields).
Return up to 200 keys, a message (4,000 characters) and an optional text file (64 KB). Everything is encrypted at
rest and shown on the order page and in the receipt. A line already delivered is never delivered twice, even when the
step retries.