Skip to main content

Crypto Billing

Ledgerline supports cryptocurrency payments via NOWPayments, a hosted custodial gateway with 200+ coins. Crypto payments are available for two use cases:

  1. Platform billing — Ledgerline charges tenants in crypto for their platform subscription/invoices.
  2. End-customer payments — Tenants can offer crypto as a checkout option for store customers.

Both paths share the same adapter and IPN webhook.


Supported Coins

TokenNetworkSymbol
BitcoinBitcoinbtc
XRPXRP Ledgerxrp
TetherTRON (TRC-20)usdttrc20
TetherEthereum (ERC-20)usdterc20
EthereumEthereumeth
LitecoinLitecoinltc
DogecoinDogecoindoge
BNBBNB Smart Chainbnb
MATICPolygonmatic

The live list is fetched from the NOWPayments /currencies endpoint and cached for 24 hours in Valkey. If a coin drops out of the list it will no longer appear as available.


Customer Payment Flow

  1. Customer selects a crypto coin at checkout.
  2. Ledgerline calls NOWPayments POST /invoice and returns a hosted payment URL.
  3. The customer is redirected to the NOWPayments hosted page, where they see the exact crypto amount and the wallet address.
  4. NOWPayments monitors the blockchain and fires an IPN webhook to Ledgerline when the payment status changes.
  5. Ledgerline enqueues an outbox message for the relevant event:
    • finished → marks the invoice/order as paid.
    • partially_paid → flags for manual reconciliation (see runbook).
    • failed / expired → marks the invoice failed.

Invoice Expiry

NOWPayments invoices expire roughly 20 minutes after creation by default. The adapter uses the expiration_estimate_date from the API response when available. After expiry the customer must start a new checkout.

NOWPayments Fee

0.5% of each transaction, deducted by NOWPayments from the received amount. Ledgerline does not mark up this fee.


Admin Configuration

Environment Variables

VariableRequiredDescription
NOWPAYMENTS_API_KEYYes (if crypto enabled)API key from NOWPayments dashboard → API Keys.
NOWPAYMENTS_IPN_SECRETYes in productionHMAC-SHA512 IPN secret, set in NOWPayments → IPN Settings.
NOWPAYMENTS_API_URLNoOverride API URL. Defaults to production endpoint. Set to https://api-sandbox.nowpayments.io/v1 for sandbox testing.

Set all three in the Render Dashboard (never commit them to the repo).

Enabling Crypto Payments

  1. Create a NOWPayments account at nowpayments.io.
  2. Obtain an API key from Dashboard → API Keys.
  3. Set your IPN callback URL in Dashboard → IPN Settings to: https://<your-render-url>/api/nowpayments/webhook
  4. Copy the IPN secret displayed after saving.
  5. Set NOWPAYMENTS_API_KEY and NOWPAYMENTS_IPN_SECRET in Render.
  6. (Optional) Set NOWPAYMENTS_API_URL to the sandbox URL while testing.

Disabling Crypto Payments

Remove (or leave blank) NOWPAYMENTS_API_KEY. When the key is absent, the CryptoPaymentPort is unbound and the adapter is not instantiated. No crypto invoice creation will be possible. The IPN webhook endpoint will still be registered but will fail gracefully (no outboxService → endpoint not registered).


Reconciliation

Crypto payments are occasionally under-paid due to network fees, exchange rate slippage, or user error. When NOWPayments reports a partially_paid status, Ledgerline enqueues an outbox message of kind nowpayments_partial_payment. This message:

  • Does NOT automatically confirm the order.
  • Triggers a notification to Michael (platform admin) and the tenant admin.
  • Requires manual review — see the crypto incidents runbook.

Sandbox / Test Mode

Set NOWPAYMENTS_API_URL=https://api-sandbox.nowpayments.io/v1 to use the NOWPayments sandbox. The sandbox issues test invoices with fake addresses and simulates payment events. You can trigger payment status changes from the NOWPayments sandbox dashboard.

For local development without a secret, set IS_PRODUCTION=false (the default for CONFIG_ENV != prod). The IPN endpoint will accept unsigned requests so you can fire webhooks manually with curl.