-
Notifications
You must be signed in to change notification settings - Fork 0
Subscription Auto‐Pay
The CLINK plugin supports automatic payments for subscription invoices using the nDebit protocol — a Nostr-native payment authorization mechanism.
An ndebit1... string is a Bech32-encoded payment authorization that allows a third party (your BTCPay Server) to initiate Lightning payments on your behalf. It's similar to a standing order or direct debit, but for Lightning payments over Nostr.
When a customer provides their nDebit string, the plugin can automatically pay future subscription invoices without requiring the customer to manually scan a QR code each time.
- Customer subscribes to a recurring service on your BTCPay Store
- At checkout, the customer enters their
ndebit1...string - The plugin stores the nDebit string linked to the customer's email
- For future subscription invoices, the plugin automatically pays using the stored nDebit
Subscription Invoice Created
│
▼
Look up customer email → Find stored nDebit
│
▼
nDebit found? ──Yes──► Auto-pay via Nostr (kind 21002)
│ │
No ▼
│ Payment confirmed
▼
Show QR code for manual payment
When a subscription invoice is detected at checkout, a special Auto-Pay with nDebit section appears above the payment box:
- Enter your
ndebit1...string in the input field - Click Pay with nDebit
- The plugin:
- Stores your nDebit linked to your buyer email
- Attempts to auto-pay the current invoice
- Saves the nDebit for future subscription invoices
Customers can also set up auto-pay via the standalone nDebit setup page:
URL: /clink/ndebit-setup?storeId={storeId}&email={email}
This page can be linked from:
- Subscription confirmation emails
- Customer portal pages
- Direct links from the merchant
If a portalSessionId is provided, the page automatically resolves the store and customer email from the portal session:
/clink/ndebit-setup?portalSessionId={session-id}
Currently, nDebit is supported by:
| Wallet | nDebit Support |
|---|---|
| ShockWallet (Browser Extension) | ✅ |
To find your nDebit string in ShockWallet:
- Open the ShockWallet browser extension
- Go to your wallet settings
- Find the nDebit or Auto-Pay section
- Copy your
ndebit1...string
If the store is configured with an nDebit in the connection string:
type=clink-noffer;noffer=noffer1...;ndebit=ndebit1...
Every new invoice is automatically paid using this nDebit when created. This is useful for merchant-controlled auto-pay scenarios.
When a customer provides their nDebit at checkout:
- The nDebit is stored via
EmailNdebitStorelinked to{storeId}:{email} - When a new subscription invoice is created for the same email:
- The plugin looks up the stored nDebit
- If found, automatically pays the invoice via the Nostr bridge
- Returns a
LightningInvoicewith statusPaidimmediately
After auto-payment, the plugin:
- Marks the invoice as paid in the
NostrEventStore - Returns the preimage from the Nostr bridge response
- BTCPay Server processes the payment normally
- nDebit strings are stored per-store, not shared across stores
- Customer emails are used as the lookup key (normalized to lowercase)
- The nDebit only authorizes payments to the specific merchant relay encoded in the string
- Each auto-pay call generates a fresh ephemeral Nostr keypair
- Customers can revoke access by rotating their nDebit in their wallet
- nDebit strings are stored in BTCPay Server's encrypted store settings
- Email addresses are stored in BTCPay's standard customer data
- Nostr communication uses NIP-44 encryption
- Payment amounts are visible to the merchant's Lightning node (standard for Lightning payments)