Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • A Ahad Mobile
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • holatech
  • Ahad Mobile
  • Merge requests
  • !85

feat(card-account): move card money paths from reap to keysecure

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Khanh Pham requested to merge feat/keysecure-card-core into develop Oct 01, 2026
  • Overview 0
  • Commits 24
  • Pipelines 1
  • Changes 125

Summary

Removes the Reap card rail from the money paths and moves card funding fully onto KeySecure (credit mode, account.transfer per cardholder).

  • Card ledger: new card_accounts / card_account_entries (one USD balance per user, migration 1790000000000), outside the reap module.
  • Transfers outbox: card_transfers with conditional PENDING → APPLIED/FAILED settles, idempotent source hooks retried until source_settled_at is set, and a sweeper.
  • Issuance: virtual card apply with fee hold, refund on explicit refusals only, apply sweeper, Card_update handling.
  • Money paths: POST /card-account/deposit (fiat wallet → card) and Convert both ways now push account.transfer In/Out; card → USDC is provider-first.
  • Consumption webhooks: posted on Success only; replay scheduler; staleness guard for reversals/refunds.
  • Rail / reconciliation: rail KEYSECURE replaces REAP; CARD, CARD_FLOAT, CARD_ACCOUNTS invariants read from one snapshot.
  • Consumers: balance and chats repointed; chat card-to-card transfer now returns 422 CARD_TRANSFER_UNAVAILABLE; legacy POST /cards/:id/deposit returns 400; Reap top-up sweeper unregistered.

API changes for the app (SP4b)

  • Convert quote no longer takes cardId.
  • New endpoints under /card-account and /card-account/cards/*.

Deploy / cutover

  • New env: KEYSECURE_CARD_PACKAGE_NO, RAIL_FLOOR_KEYSECURE_USD. Removed: KEYSECURE_RESERVE_LOW_USD.
  • Run migration 1790000000000-create-card-account-tables.
  • One-off data step on staging/prod: reset normal.CARD_USD (still holds the old Reap card float) and fund reserve.CARD_USD to mirror the KeySecure reserve fund, otherwise deposits fail.
  • Set provide_card_fee_virtual = 0.

Testing

  • Jest (card-account, transactions, conversion, treasury, cards, keysecure): 1079 tests pass. ramp-limits.velocity fails on date math and was already failing on develop.
  • Postgres specs (RUN_DB_TESTS=1, -i) pass, including the new reconciliation.card-flow.postgres.spec.ts that drives deposit, Convert both ways, refund and consumption postings. ramp-netting.postgres refuses a non-localhost DB host (pre-existing).
  • eslint on changed files clean; yarn build passes.
  • Sandbox smoke not run yet: card issuance is blocked until the sandbox reserve fund is topped up (/card/apply returns 3008).

Known follow-ups

  • A short reserve.CARD_USD on deposit surfaces as a 400 with an internal account id; should map to 502/503 + ALERT.
  • Code 3008 (insufficient balance) is not yet classified as a refusal on card apply.
  • Freeze / client-token transport errors still return 500.

🤖 Generated with Claude Code

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: feat/keysecure-card-core