Skip to content

Subscription-level amount→cost pricing (get_cost_by_amount for non-VM subscriptions) #181

Description

@v0l

PricingEngine::get_cost_by_amount only prices VM-backed subscriptions (it looks up the VM's template/custom pricing). Callers that need to turn an arbitrary paid amount into time for a non-VM subscription (e.g. IP range, DNS, ASN line items) have no equivalent.

Current workaround: the on-chain payment watcher (lnvps_api/src/payments/onchain.rs, OnChainPaymentHandler::regenerate) falls back to scaling the payment's original quote by the value received at the current exchange rate when get_vm_by_subscription fails. This works but re-uses stale quote pricing instead of current line-item pricing.

Proposal: add a subscription-level equivalent, e.g.

PricingEngine::get_subscription_cost_by_amount(
    subscription_id: u64,
    input: CurrencyAmount,
    method: PaymentMethod,
) -> Result<CostResult>

priced from the subscription's line-item amounts and billing interval (interval_amount / interval_type), with the same tax determination and processing-fee handling as the VM path. Then:

  • the on-chain watcher can drop its quote-scaling fallback and regenerate all payments uniformly
  • LNURL-style ad-hoc top-ups become possible for non-VM subscriptions

Related: #109 (on-chain payments, where the fallback was introduced — see PR #180).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpaymentsPayment/invoice logic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions