Webhooks
Decision hooks
Before a customer pays, we ask your hook whether they may buy (voucher.pre_purchase under Webhooks below). Answer a 2xx within your timeout (at most 2.5 seconds), at most 10 KB; anything else counts as your server failing, and the hook's own choice applies: stop the purchase, or let it through. After 10 failures in a row we stop calling and keep applying that choice, trying once every 30 seconds until you answer.
Decide on customer.externalId, never on anything a customer types: an email proves nothing unless emailVerified is true. Answer "requireLink": true to have them verify on your verification page: we send them there with state, uid and callback, valid 15 minutes. Send them back to callback with state, external_id, t and sig, an HMAC-SHA256 of t, a dot, state, a dot, then external_id, with the hook's secret, within 15 minutes. From then on every call carries your externalId.
1// On your verification page, after your own login succeeds.2// Check query.callback starts with your OgaWiFi address first, or the page3// becomes a way to send people anywhere.4function callbackUrl(query, member, secret) {5 const t = Math.floor(Date.now() / 1000);6 const sig = crypto7 .createHmac("sha256", secret)8 .update(`${t}.${query.state}.${member.id}`)9 .digest("hex");10 const url = new URL(query.callback);11 url.searchParams.set("state", query.state);12 url.searchParams.set("external_id", member.id);13 url.searchParams.set("t", String(t));14 url.searchParams.set("sig", sig);15 return url.toString(); // redirect the browser here16}We store whatever you vouch for. If a member should only ever be linked to one account, remember the uid you linked them to and refuse a second. On the captive portal, your verification page's host is let through the router's walled garden automatically; anything it loads from other hosts is not, so keep it self-contained.