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"
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:
- Parse
tandv1from the header; reject a malformed header. - Reject a
tmore than 5 minutes old (replay protection). - Compute the HMAC over the raw request body, before any JSON parsing.
- Compare with
v1in 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\"}"
}
| Field | Description |
|---|---|
invoiceId | Lightning Enable invoice ID (numeric string) |
orderId | Your order ID |
status | Route on this field (see below) |
amount / currency | As created |
providerChargeId + provider | Strike ("strike") and NWC ("nwc"; the charge ID is the payment hash) |
openNodeChargeId | OpenNode merchants, in place of the two fields above |
paidAt | When Lightning Enable processed the event (UTC) |
metadata | The 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
| Status | Meaning | Action |
|---|---|---|
paid | Payment confirmed | Fulfill the order |
processing | Payment seen, not final (includes OpenNode underpayments) | Wait |
expired | Invoice expired unpaid | Release the order or create a new payment |
refunded | Payment refunded | Update 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-
2xxresponse 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 oninvoiceId+status, never on the signature header. - After the last retry the event is marked failed. Reconcile pending orders with
GET /api/payments/{invoiceId}, orPOST /api/payments/{invoiceId}/syncto 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.
- Hash the raw body, not re-serialized JSON.
- Sign
{t}.{body}, not the body alone. - Use the
webhookSecretyou set, not an API key. - 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
- Webhooks API Reference: full reference and verifiers
- Errors: error codes