Skip to main content

Webhooks

When a payment's status changes, Lightning Enable posts a signed JSON payload to your callback URL. Use webhooks to fulfill orders, and keep GET /api/payments/{invoiceId} as the authoritative fallback.

Setup​

1. Set your callback URL and secret​

Generate a secret (for example, openssl rand -hex 32) and keep a copy. Lightning Enable never returns it, and your account's initial secret is not readable, so set your own:

curl -X PUT https://api.lightningenable.com/api/merchant/webhook-url \
-H "X-API-Key: your-merchant-api-key" \
-H "Content-Type: application/json" \
-d '{
"webhookUrl": "https://yourapp.com/webhooks/lightning",
"webhookSecret": "your-webhook-secret"
}'

Or send only webhookUrl and let Lightning Enable generate the secret: rotate it, and store the value the response returns. The merchant API returns it only in that response; to get a value again, rotate again.

curl -X POST https://api.lightningenable.com/api/merchant/webhook-secret/rotate \
-H "X-API-Key: your-merchant-api-key"

See Rotate Webhook Secret.

Your endpoint must accept POST, be reachable over HTTPS, and return a 2xx within 10 seconds.

2. Verify the signature​

Every delivery carries an X-LightningEnable-Signature header:

X-LightningEnable-Signature: t=1735689600,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8f9

v1 is the lowercase hex HMAC-SHA256 of {t}.{raw_body}, keyed with your webhook secret. To verify:

  1. Parse t and v1 from the header; reject a malformed header.
  2. Reject a t more than 5 minutes old (replay protection).
  3. Compute the HMAC over the raw request body, before any JSON parsing.
  4. Compare with v1 in constant time.

Copy a tested verifier from Verifying Webhooks (Node.js, C#, Python).

3. Handle the event​

// Express: express.raw() keeps the exact bytes the signature covers
app.post('/webhooks/lightning', express.raw({ type: 'application/json' }), async (req, res) => {
const payload = req.body.toString('utf8');
const header = req.headers['x-lightningenable-signature'];

if (!header || !verifyWebhookSignature(payload, header, process.env.WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature');
}

res.status(200).send('OK'); // acknowledge first, then do the slow work

const event = JSON.parse(payload);
if (event.event) return; // an L402 producer event; see the API reference
if (event.status === 'paid') {
await fulfillOnce(event.orderId, event.invoiceId); // idempotent
}
});

Payload​

One flat JSON object per event, with no envelope. The provider field differs by lane:

{
"invoiceId": "1042",
"orderId": "ORDER-12345",
"status": "paid",
"amount": 25.00,
"currency": "USD",
"providerChargeId": "8f6c3f5e-1c2d-...",
"provider": "strike",
"paidAt": "2026-07-03T12:03:45Z",
"metadata": "{\"customerId\":\"cust_123\"}"
}
FieldDescription
invoiceIdLightning Enable invoice ID (numeric string)
orderIdYour order ID
statusRoute on this field (see below)
amount / currencyAs created
providerChargeId + providerStrike ("strike") and NWC ("nwc"; the charge ID is the payment hash)
openNodeChargeIdOpenNode merchants, in place of the two fields above
paidAtWhen Lightning Enable processed the event (UTC)
metadataThe metadata you supplied, as a JSON string (parse it), or null

If you sell with L402, an l402.challenge.paid event with an event field and no status arrives on the same URL. Check for event first. See L402 producer events.

Statuses​

StatusMeaningAction
paidPayment confirmedFulfill the order
processingPayment seen, not final (includes OpenNode underpayments)Wait
expiredInvoice expired unpaidRelease the order or create a new payment
refundedPayment refundedUpdate records

Refunds themselves send no webhook; poll GET /api/refunds/{refundId}.

Delivery and Retries​

  • The first attempt fires as soon as Lightning Enable sees the status change. On the NWC lane that is within a minute, because the wallet is polled.
  • A non-2xx response or a timeout is retried with exponential backoff: 30s, 60s, 120s, 240s, 480s. Every attempt sends identical payload bytes with a freshly timestamped signature, so dedupe on invoiceId + status, never on the signature header.
  • After the last retry the event is marked failed. Reconcile pending orders with GET /api/payments/{invoiceId}, or POST /api/payments/{invoiceId}/sync to re-check the provider.

Local Development​

Expose your local endpoint with a tunnel such as ngrok http 3000, then set the tunnel URL with PUT /api/merchant/webhook-url. Switch it back to your production URL before you go live.

Troubleshooting​

Nothing arrives. Confirm the URL is public HTTPS and that a firewall isn't blocking it. Then check the payment's status with GET /api/payments/{invoiceId}: if it is still unpaid, there was nothing to send yet.

Signature check fails.

  1. Hash the raw body, not re-serialized JSON.
  2. Sign {t}.{body}, not the body alone.
  3. Use the webhookSecret you set, not an API key.
  4. Read the header X-LightningEnable-Signature, and compare lowercase hex.

Duplicates. Expected. Make fulfillment a no-op for an order you have already fulfilled.

Next Steps​