Skip to content

Enable Users To Buy Auto Drive Upload Credits #465

@clostao

Description

@clostao

High-level approach

Using pallet-balances.Transfer transactions, the user creates the extrinsic, creates an invoice in auto-drive that includes information about the transaction so Auto-Drive's Payment Processor can track the payment adding the appropriate amount of credits on finalisation, and finally submits the extrinsic.

Implementation Steps:

  1. Support ‘one-of’ credits granularity
  2. Payment processor using simple Substrate balances.transfer
  3. Callback on payment received to update upload credits

Updates in data model (minimal)

  • SubscriptionGranularity: enum [one_of, monthly]
  • New table invoices for keeping track of payment creations.

API/services

  • POST /credits/invoices → creates invoice; returns Invoice
  • GET /credits/invoices/{id} → status polling
  • PaymentMonitor service:
    • Subscribes to chain, matches transfers to the treasury address, enforces finality, triggers crediting.

Chain parameters and guardrails

  • Use chain decimals correctly for UI display.
  • Document supported chain and SS58 prefix.
  • Handle reorgs: only act on finalised blocks.

Admin panel changes

  • Product/plan form: add granularity selector with one_off default.

Sub-issues

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions