Settlement Flows
This section documents the technical flows for different settlement patterns.
Direct Settlement Flowβ
Standard settlement via the REST API.
βββββββββββ βββββββββββββββββββ ββββββββββββ βββββββββββ
β Client β β Lightning Enableβ β Provider β βLightningβ
ββββββ¬βββββ ββββββββββ¬βββββββββ ββββββ¬ββββββ ββββββ¬βββββ
β β β β
β POST /api/payments β β β
ββββββββββββββββββββ>β β β
β β Create charge β β
β ββββββββββββββββββββ>β β
β β β Invoice β
β β<ββββββββββββββββββββ β
β Invoice + ID β β β
β<ββββββββββββββββββββ β β
β β β β
β [Client pays invoice via Lightning wallet] β
β β β β
β β Webhook: paid β β
β β<ββββββββββββββββββββ β
β Webhook: settled β β β
β<ββββββββββββββ ββββββ β β
β β β β
Endpointsβ
Settlements ride on the Payments API β there is no separate settlements endpoint:
POST /api/payments- Create an invoice (a settlement request)GET /api/payments/{invoiceId}- Check settlement statusPOST /api/payments/{invoiceId}/sync- Force a status sync from your payment providerPOST /api/webhooks/strike/POST /api/webhooks/opennode- Where your payment provider notifies Lightning Enable; Lightning Enable then forwards a signed webhook to your callback URL
L402 Settlement Flowβ
Per-request settlement using HTTP 402 challenges.
βββββββββββ βββββββββββββββββββ ββββββββββββ
β Client β β Lightning Enableβ β Provider β
ββββββ¬βββββ ββββββββββ¬βββββββββ ββββββ¬ββββββ
β β β
β GET /resource β β
ββββββββββββββββββββ>β β
β β Create charge β
β ββββββββββββββββββββ>β
β β<ββββββββββββββββββββ
β 402 + Invoice β β
β<ββββββββββββββββββββ β
β β β
β [Client pays, receives preimage] β
β β β
β GET /resource β β
β Auth: L402 token β β
ββββββββββββββββββββ>β β
β β Verify preimage β
β 200 + Content β β
β<ββββββββββββββββββββ β
β β β
L402 Header Formatβ
Request:
Authorization: L402 <macaroon>:<preimage>
Challenge response (402):
WWW-Authenticate: L402 macaroon="<base64>", invoice="<bolt11>"
Webhook Flowβ
Settlement confirmation via webhooks.
ββββββββββββ βββββββββββββββββββ ββββββββββββ
β Provider β β Lightning Enableβ β Your App β
ββββββ¬ββββββ ββββββββββ¬βββββββββ ββββββ¬ββββββ
β β β
β POST /webhooks β β
β (settlement event) β β
βββββββββββββββββββββ>β β
β β Verify signature β
β β Update state β
β β β
β β POST /your-webhook β
β βββββββββββββββββββββ>β
β β β Process
β β 200 OK β
β β<βββββββββββββββββββββ
β 200 OK β β
β<βββββββββββββββββββββ β
β β β
Webhook Signature Verificationβ
X-LightningEnable-Signature: t={unix_timestamp},v1={hmac_sha256_hex}
Verify by computing HMAC-SHA256 of {timestamp}.{payload} using your webhook secret. Reject signatures older than 5 minutes. See Webhook Verification for full details and code examples.
Settlement Statesβ
| State | Description | Terminal |
|---|---|---|
unpaid | Invoice created, awaiting settlement | No |
processing | Settlement detected, confirming | No |
paid | Settlement complete | Yes |
expired | Invoice expired | Yes |
refunded | Settlement was refunded | Yes |
These are the same status values returned by the Payments API and forwarded in webhooks.
Further Readingβ
- API Reference - Complete API documentation
- Webhooks - Webhook implementation details
- L402 Protocol - L402 technical details