Event catalogue
Generated from the same module the emitter is typed against, so it cannot list an event nothing sends. Your dashboard serves the same list, with a sample payload for each.
| type | When it fires | State |
|---|---|---|
| payment_intent.created | A payment was created and is waiting to be confirmed. | |
| payment_intent.processing | The payment was routed to a provider and is under way. | |
| payment_intent.requires_action | The customer has to approve a prompt, enter a code or finish a redirect. | |
| payment_intent.succeeded | The funds are confirmed. Fulfil the order here. | |
| payment_intent.failed | Terminal failure, with a canonical code saying why. | |
| payment_intent.canceled | Cancelled before it completed. | |
| payment_intent.expired | The customer never completed it in time. | |
| charge.succeeded | One attempt took the money. | |
| charge.failed | One attempt was declined. The payment may still succeed elsewhere. | |
| refund.succeeded | The provider confirmed the refund: the money is back with the payer and the reversal is booked. | |
| refund.failed | The provider refused the refund. Nothing was booked and nothing retries on its own. | |
| dispute.created | A dispute was opened — by a buyer (source CUSTOMER) or as a chargeback (PROVIDER). The disputed amount is held. | |
| dispute.accepted | You accepted a buyer’s dispute: the hold is released and a refund requested. The buyer has not been paid yet. | |
| dispute.rejected | You rejected a buyer’s dispute: the hold is released and you keep the sale. Stored as WON. | |
| payout.paid | A payout arrived — your app’s own, or one to a marketplace seller, whom seller names. | |
| payout.failed | A payout failed. failureCode and failureMessage say why. | |
| balance.updated | Your available balance changed. | Not yet emitted |
The payload
One envelope for every event: an id to deduplicate on, a type to branch on, the environment, and the object itself under data.object. Amounts are decimal strings and the object’s dates are epoch milliseconds, exactly as everywhere else; the envelope’s own created is in seconds, like the signature timestamp.
import { createHmac, timingSafeEqual } from 'node:crypto';
// The raw bytes, not the parsed body. Express's JSON parser re-serialises,
// and the re-serialised bytes will not match the HMAC we computed.
app.post('/webhooks/nyukiai', express.raw({ type: 'application/json' }),
(req, res) => {
if (!verify(req.body, req.get('NyukiAI-Signature'))) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body.toString('utf8'));
// Delivery is at-least-once and can arrive out of order. Deduplicate on
// the id, and compare against your own state rather than assuming order.
if (alreadyProcessed(event.id)) return res.sendStatus(200);
if (event.type === 'payment_intent.succeeded') {
fulfil(event.data.object.reference); // <- fulfil HERE
}
res.sendStatus(200);
});Verifying the signature
The NyukiAI-Signature header carries a timestamp and an HMAC over "{timestamp}.{raw body}". Verify it before you trust a single field.
# NyukiAI-Signature: t=1785869000,v1=5257a869e7…
#
# signed_payload = "{t}.{raw_body}"
# expected = HMAC-SHA256(endpoint_secret, signed_payload)
#
# Compare in constant time, and reject anything where |now - t| is more than
# five minutes. Without the timestamp in the signed string, a captured request
# would verify forever.
#
# During a secret rotation BOTH the new and the previous secret sign, so you
# can deploy the new one without a synchronised cutover.Four rules that are not optional
Every integration that has ever gone wrong here went wrong on one of these.
- Fulfil on payment_intent.succeeded from the webhook, never on the HTTP response to confirm. A device-push payment is not complete when that call returns.
- Expect duplicates. Delivery is at-least-once — deduplicate on the envelope id.
- Expect events out of order. Compare against your own stored state rather than assuming a sequence.
- Verify the signature against the raw bytes. A parsed and re-serialised body will not match the HMAC, and that mistake is invisible until production.
- Answer 2xx quickly and do your work afterwards. Anything else is counted as a failure, and twenty consecutive failures disables the endpoint.
Replaying an event
Any past event can be sent again from Developers → Events, either to every subscribed endpoint or to one that missed it.
