Designing Bitcoin Billing SDKs for Hosting Platforms
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Billing model
Hosting billing adds service periods, renewals, credits and provisioning to payment monitoring. A specialized SDK should bind each payment intent to an immutable invoice revision and customer account. The billing system owns tax, pricing, exchange quotes and service eligibility. Bitcoin transfers are payer-initiated; an invoice renewal does not authorize automatic wallet spending. Never present a watch as a recurring debit mandate.
Conceptual Python workflow
def process_invoice(invoice, evidence, ledger, outbox):
if not invoice.policy.accepts(evidence):
return "pending_review"
with ledger.transaction():
if ledger.allocate_once(invoice.id, evidence.output_key):
outbox.enqueue_once(invoice.id, "provision_service")
return "recorded"This pseudocode assumes a normalized verified output and an outbox sharing the ledger transaction. It does not represent an engine response. A real implementation validates amount, network, destination, confirmation and invoice revision. Multiple outputs require a separate aggregation policy. Provisioning credentials must remain separate from wallet credentials.
Lifecycle and failure handling
Keep invoice states separate from service states: a paid invoice may have failed provisioning, and a suspended service may still receive a late payment. Use idempotent provisioning jobs and reconcile the provider's actual resource identifier after uncertain responses. Define grace periods and manual review for underpayment, late payment and reorganization. Avoid irreversible service deletion based solely on a temporary engine outage. Refunds require separate authorization and disclosure of fee effects. A WHMCS adapter can implement these contracts after its current gateway interfaces are verified; no specific hook compatibility is asserted here.
Acceptance plan
Simulate duplicate callbacks, worker crashes after provisioning, expired quotes, partial payments and renewal races. On Testnet, settle an invoice and provision a disposable resource or mock service exactly once. Compare billing records with actual payment evidence and separately record provisioning costs.
Primary reference
https://thamer.org/api
Related reading
https://thamer.org/docs/wab-sdk-api-engine-application-boundaries
https://thamer.org/docs/wab-sdk-authentication-credential-management
https://thamer.org/docs/wab-sdk-watch-payment-monitoring
https://thamer.org/docs/wab-sdk-invoice-abstractions
https://thamer.org/docs/wab-sdk-confirmation-settlement-states
https://thamer.org/docs/wab-sdk-payment-reconciliation
https://thamer.org/docs/wab-sdk-immutable-fee-policy
