fix(storev2): centralize QPay invoice persistence#234

draft1
v2
orch/2026-07-18T08-42-00-926Z-2efb3c4e/issue212-author
openedJul 18, 2026byAAviddaram
View on GitHubTwo-way sync enabledPR last imported 20d ago

Summary

  • centralize QPay invoice lookup, amount conversion, provider creation, KV/database persistence, and tracking in one Payment-owned operation
  • await the canonical operation in the fallback route
  • register non-fatal eager creation with the Worker execution context and sanitize its failure log

Validation

  • bun run build (8/8 workspaces passed)
  • bunx biome lint packages/api/src/routers/store/order.ts packages/api/src/routers/store/payment.ts (passed; two existing complexity warnings)
  • focused server typecheck reached only unrelated baseline declaration errors outside the changed files
  • structural proof confirms a single route-level createQpayInvoice caller and both eager/fallback call sites use createAndStoreQpayInvoice

Proof limitation

No local environment files, configured non-production QPay boundary, local database, or local KV were available in this isolated worktree. No provider call was made. This PR remains draft pending approved real boundary proof.

Addresses #212

Note

Centralize QPay invoice creation and persistence into a shared createAndStoreQpayInvoice function

  • Extracts QPay invoice creation, KV caching (1h TTL), DB update, and tracking into a new exported createAndStoreQpayInvoice function in payment.ts.
  • The payment router's QR/invoice handler now delegates to this shared function on a KV cache miss, replacing duplicated inline logic.
  • The order router replaces a fire-and-forget promise with ctx.c.executionCtx.waitUntil(...), so failures emit a structured warn log instead of being silently dropped.

Macroscope summarized 5cbd618.

Checks

4 successful · 1 skipped
All checks passed
f597bef

Added 1 commit

  • fix(storev2): centralize QPay invoice persistencef597bef
Synced from GitHub

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

yaml
1reviews:
2 auto_review:
3 drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.