Payments API
Create Lightning invoices and manage payment status.
Create Payment
Create a new Lightning invoice for a customer payment.
POST /api/payments
Request Headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | Your merchant API key |
Content-Type | Yes | application/json |
X-Idempotency-Key | No | Makes a retry return the first response instead of a second invoice. See Request Headers |
Request Body
{
"orderId": "ORDER-12345",
"amount": 49.99,
"currency": "USD",
"description": "Premium Subscription",
"customerEmail": "customer@example.com",
"expiresInSeconds": 900,
"metadata": {
"productId": "prod_123",
"userId": "user_456"
}
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Your unique order identifier (1–100 chars) |
amount | decimal | Yes | Payment amount in currency. 0 creates a demo invoice that auto-confirms without real payment |
currency | string | Yes | Uppercase 3-letter code (USD, EUR, GBP, BTC) — anything else fails validation |
description | string | No | Payment description (max 500 chars) |
customerEmail | string | No | Customer email for receipt |
customerName | string | No | Customer name (max 200 chars) |
successUrl | string | No | URL to send the customer to after payment |
metadata | object | No | Custom key-value data — string values only |
expiresInSeconds | integer | No | How long the invoice stays payable, from 60 to 86400 (1 minute to 24 hours). Leave it out to use your payment provider's default lifetime (about 24 hours on Strike). A value outside the range, or one that isn't a whole number, is 400 invalid_expiry. See Invoice Expiration |
Response
{
"invoiceId": "1042",
"status": "unpaid",
"amount": 49.99,
"currency": "USD",
"lightningInvoice": "lnbc1250000n1pnxyz...",
"paymentHash": "a1b2c3d4e5f6...",
"onchainAddress": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"hostedCheckoutUrl": "https://checkout.opennode.com/abc123",
"payUrl": "https://api.lightningenable.com/pay/YOUR_PAYMENT_TOKEN",
"providerChargeId": "charge_abc123",
"openNodeChargeId": "charge_abc123",
"createdAt": "2026-07-03T12:00:00Z",
"expiresAt": "2026-07-03T13:00:00Z"
}
| Field | Notes |
|---|---|
invoiceId | Lightning Enable invoice ID — a numeric string (e.g. "1042"). Use it for status lookups |
lightningInvoice | BOLT11 invoice to display / encode as a QR code |
paymentHash | The invoice's payment hash — use this instead of parsing the BOLT11 yourself |
onchainAddress | On-chain fallback address, when the provider supplies one |
hostedCheckoutUrl | Provider-hosted checkout page — OpenNode only; empty for Strike merchants |
payUrl | Lightning Enable's own hosted checkout page for this invoice. Treat it as a secret — see below |
expiresAt | When the invoice stops being payable, read from the BOLT11 invoice itself (its creation time plus its expiry). Always honor this field (see Invoice Expiration) |
payUrl is a payment link, not a public URLThe path segment after /pay/ is a random per-invoice token, and holding it is what authorizes the checkout page: anyone with the URL can see that invoice's amount, description, merchant name and BOLT11 invoice. Send it to the buyer, and keep it out of logs, referrers and crawlable pages — the same care you would give a payment link from any processor.
It cannot be derived from invoiceId, and /pay/1042 does not resolve. If you lose the URL, read payUrl back from GET /api/payments/{invoiceId} with your API key.
providerChargeId is the provider-agnostic charge identifier that works with both Strike and OpenNode. openNodeChargeId is retained for backward compatibility and will always be populated alongside providerChargeId.
Example
curl -X POST https://api.lightningenable.com/api/payments \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"orderId": "ORDER-12345",
"amount": 49.99,
"currency": "USD",
"description": "Premium Subscription"
}'
Get Payment by Invoice ID
Retrieve payment details by Lightning Enable invoice ID.
GET /api/payments/{invoiceId}
Parameters
| Parameter | Type | Description |
|---|---|---|
invoiceId | string | Lightning Enable invoice ID |
Response
{
"invoiceId": "1042",
"orderId": "ORDER-12345",
"providerChargeId": "charge_abc123",
"openNodeChargeId": "charge_abc123",
"status": "paid",
"amount": 49.99,
"currency": "USD",
"lightningInvoice": "lnbc1250000n1pnxyz...",
"onchainAddress": "bc1qxy2...",
"hostedCheckoutUrl": "https://checkout.opennode.com/abc123",
"payUrl": "https://api.lightningenable.com/pay/YOUR_PAYMENT_TOKEN",
"createdAt": "2026-07-03T12:00:00Z",
"paidAt": "2026-07-03T12:05:00Z",
"expiresAt": "2026-07-03T13:00:00Z"
}
Example
curl https://api.lightningenable.com/api/payments/1042 \
-H "X-API-Key: YOUR_API_KEY"
Public Payment Status (browser polling)
GET /api/payments/{invoiceId}/status
No API key required. Returns only { "status": "..." }, so it is safe to call from client-side code — this is the endpoint your checkout page should poll instead of embedding your API key in the browser:
{ "status": "paid" }
// Browser-safe polling
const { status } = await (await fetch(
`https://api.lightningenable.com/api/payments/${invoiceId}/status`
)).json();
Fulfillment decisions belong on your server — use webhooks or the authenticated endpoints above for the authoritative record.
Get Payment by Order ID
Retrieve payment details by your order ID.
GET /api/payments/order/{orderId}
Parameters
| Parameter | Type | Description |
|---|---|---|
orderId | string | Your order identifier |
Response
Same as Get Payment by Invoice ID.
Example
curl https://api.lightningenable.com/api/payments/order/ORDER-12345 \
-H "X-API-Key: YOUR_API_KEY"
Sync Payment Status
Force sync payment status from the payment provider. Useful if webhook was delayed.
POST /api/payments/{invoiceId}/sync
Parameters
| Parameter | Type | Description |
|---|---|---|
invoiceId | string | Lightning Enable invoice ID |
Response
Returns updated payment object with current status.
Example
curl -X POST https://api.lightningenable.com/api/payments/1042/sync \
-H "X-API-Key: YOUR_API_KEY"
Payment Statuses
| Status | Description |
|---|---|
unpaid | Invoice created, awaiting payment |
processing | Payment detected, confirming |
paid | Payment confirmed |
expired | Invoice expired without payment |
refunded | Payment was refunded |
Payment Flow
POST /api/paymentsreturnsinvoiceId,lightningInvoiceandpayUrl.- Show the invoice as a QR code (or send the buyer to
payUrl); the buyer pays from any Lightning wallet. - Your callback URL gets a webhook, or you read
GET /api/payments/{invoiceId}. - When
statusispaid, fulfill the order.
Supported Currencies
| Currency | Code | Notes |
|---|---|---|
| US Dollar | USD | Converted to BTC at current rate |
| Euro | EUR | Converted to BTC at current rate |
| British Pound | GBP | Converted to BTC at current rate |
| Bitcoin | BTC | Direct amount as a decimal with up to 8 places — for satoshi precision, use BTC (e.g. 0.00062500 = 62,500 sats) |
Currency codes must be uppercase 3-letter values — there is no sats currency code; lowercase or 4-letter values fail validation with a 400.
If your account settles into your own wallet over Nostr Wallet Connect, send BTC (amount in bitcoin) or SAT (whole satoshis), between 1 satoshi and 21,000,000 BTC. A fiat code returns 400 currency_not_supported, and an amount out of range returns 400 amount_too_small or amount_too_large; see NWC Request Refused. An omitted currency defaults to USD, so always set it.
On the Nostr Wallet Connect lane (your own wallet), only BTC is accepted: a Lightning wallet has no exchange rate to convert fiat with.
Invoice Expiration
Set the lifetime yourself with expiresInSeconds (60 to 86400). Without it, the lifetime is your payment provider's default. Either way, read expiresAt from the response instead of assuming a window: it's the deadline encoded in the BOLT11 invoice, which is the one a payer's wallet enforces.
| Provider | Without expiresInSeconds | With expiresInSeconds |
|---|---|---|
| Strike (recommended default) | About 24 hours | Sent as bolt11.expiryInSeconds on Strike's create receive request |
| OpenNode | 24 hours (OpenNode's ttl default) | Sent as ttl in whole minutes, rounded down. OpenNode's minimum is 10 minutes, so a value under 600 gets a 10-minute invoice; expiresAt shows the real deadline |
| Your own wallet (NWC) | The wallet's default | Sent as expiry on the NIP-47 make_invoice request. A wallet that ignores it shows its own deadline in expiresAt |
Demo invoices (amount: 0) | 10 minutes | The value you send |
If the provider refuses the request (for example, an expiry it won't accept), the response is 502 payment_provider_rejected with the provider's reason in message. If the provider is down (it answered with a 5xx), the response is 502 payment_provider_unavailable: retry later. Either way no invoice is created, and retryable says whether retrying the same request can succeed.
When a price only holds for a while, mint the invoice to die with it. The Lightning Enable Store's custom-product checkout does this: it sets expiresInSeconds to the time left on the price quote, because an order is refused with 400 invoice_outlives_quote when its invoice stays payable more than an hour (by default) past the quote's expiry.
After expiration an invoice can't be paid — create a new payment.
Error Responses
Errors are JSON with an error field. Some are prose; dispatch those on the HTTP status:
// 400 — business validation (e.g. duplicate order)
{ "error": "Invoice already exists for OrderId ORDER-12345" }
// 404 — unknown invoice, or another account's
{ "error": "Invoice 1042 not found for merchant 42" }
These create-payment errors carry a machine-readable error code and a message. The 502 bodies below are illustrative: message and providerStatus carry whatever the provider actually answered.
// 400 — expiresInSeconds outside 60..86400, or not a whole number
{
"error": "invalid_expiry",
"message": "expiresInSeconds must be a whole number between 60 and 86400 seconds (1 minute to 24 hours), or omitted to use the payment provider's default invoice lifetime. Nothing was created.",
"minExpiresInSeconds": 60,
"maxExpiresInSeconds": 86400
}
// 400 — no payment provider credential on your account (same body on POST /api/payments/{invoiceId}/sync)
{
"error": "payment_provider_not_configured",
"message": "No payment provider API key is configured on this account, so no Lightning invoice could be created and nothing was charged. ...",
"docs": "https://docs.lightningenable.com/strike-setup/account-setup"
}
// 503 — your own wallet (NWC lane) is busy; sent with Retry-After: 2
{
"error": "payment_provider_busy",
"message": "The Lightning wallet settling this payment is busy serving other requests and did not free a slot in time, so no invoice was created and nothing was charged. ...",
"docs": "https://docs.lightningenable.com/nwc-setup/account-setup"
}
// 502 — the payment provider refused to create the invoice (illustrative)
{
"error": "payment_provider_rejected",
"message": "The payment provider (strike) refused to create the invoice (HTTP 422): INVALID_DATA: Invalid data. (bolt11.expiryInSeconds: Value is out of range.) Nothing was created. Fix the request and retry; if it persists, contact support@lightningenable.com.",
"provider": "strike",
"providerStatus": 422,
"retryable": false
}
// 502 — the payment provider is down (illustrative)
{
"error": "payment_provider_unavailable",
"message": "The payment provider (strike) is unavailable (HTTP 503), so no invoice was created. Retry later; if it persists, contact support@lightningenable.com.",
"provider": "strike",
"providerStatus": 503,
"retryable": true
}
Model-binding failures (missing orderId, malformed currency, negative amount) return the standard ASP.NET validation problem shape — a 400 with an errors dictionary keyed by field name. See Errors for the full contract.
Code Examples
JavaScript
async function createPayment(orderId, amount, currency) {
const response = await fetch('https://api.lightningenable.com/api/payments', {
method: 'POST',
headers: {
'X-API-Key': process.env.LIGHTNING_ENABLE_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ orderId, amount, currency })
});
if (!response.ok) {
const { error, message } = await response.json();
throw new Error(`Payment failed (${response.status} ${error}): ${message ?? ''}`);
}
return response.json();
}
// Usage
const payment = await createPayment('ORDER-123', 49.99, 'USD');
console.log('Lightning Invoice:', payment.lightningInvoice);
Python
import os
import requests
def create_payment(order_id, amount, currency):
response = requests.post(
'https://api.lightningenable.com/api/payments',
headers={
'X-API-Key': os.environ['LIGHTNING_ENABLE_API_KEY'],
'Content-Type': 'application/json'
},
json={
'orderId': order_id,
'amount': amount,
'currency': currency
}
)
response.raise_for_status()
return response.json()