# Cryptocurrency Payment Orchestrator

Handles cryptocurrency payments for Lilith premium content. The orchestrator
coordinates wallet handoff, quote construction, compliance, settlement
verification, revenue distribution, and access provisioning.

## Pipeline

1. **Compliance guard** – validates purchase intent and settlement safety.
2. **Content catalog** – retrieves premium content metadata, pricing, and access
   policy.
3. **Pricing engine** – emits on-chain quotes with fee and revenue split
   breakdowns.
4. **Wallet gateway** – generates smart contract call data and verifies
   settlement receipts.
5. **Session store** – persists payment session state transitions and expiry.
6. **Ledger** – records authorizations, settlements, and failure trails.
7. **Royalty splitter** – computes creator/platform/treasury payouts per
   settlement.
8. **Access manager** – activates premium content access following confirmed
   payment.
9. **Notification service** – informs the buyer and stakeholders of lifecycle
   events.
10. **Analytics reporter** – publishes metrics for observability and financial
    reporting.

## Usage

```ts
import { createCryptoPaymentService } from './service';

const service = createCryptoPaymentService({
  contentCatalog,
  pricingEngine,
  walletGateway,
  sessionStore,
  ledger,
  royaltySplitter,
  accessManager,
  notificationService,
  analyticsReporter,
  complianceGuard,
});

const session = await service.createPaymentSession({
  contentId: 'premium-meditation-aurora',
  walletAddress: '0xuserwallet',
  chainId: 137,
  quantity: 1,
  locale: 'en-US',
  referralCode: 'LUMINA2025',
});

await service.confirmSettlement({
  sessionId: session.sessionId,
  transactionHash: '0xsettle',
});
```

## Tests

```bash
npx jest --config apps/lilith/svc-payment-orchestrator/jest.config.cjs --runInBand
```
