veza/veza-backend-api/internal/core
senke 36ee3da1b4 refactor(marketplace): extract refund flow into service_refunds.go
marketplace/service.go was at 1737 LOC with nine distinct concerns
crammed into one file. The refund flow is the most cleanly isolated :
no caller outside the file, no shared helpers, all four refund-related
sentinels declared right next to the methods that use them. Lifted
into service_refunds.go without touching signatures.

What moved (5 declarations + 5 functions, 397 LOC) :
  - refundProvider interface
  - ErrOrderNotRefundable, ErrRefundNotAvailable, ErrRefundForbidden,
    ErrRefundAlreadyRequested sentinels
  - RefundOrder           (Phase 1/2/3 PSP coordination)
  - ProcessRefundWebhook  (Hyperswitch webhook dispatcher)
  - finalizeSuccessfulRefund (terminal: succeeded)
  - finalizeFailedRefund     (terminal: failed)
  - reverseSellerAccounting  (helper: undo seller balance + transfers)

Same package (marketplace), same Service receiver — pure code-org
move. `go build ./internal/core/marketplace/...` clean ;
`go test ./internal/core/marketplace -short` passes.

service.go is now 1340 LOC ; eight other concerns remain in it
(product CRUD, order create/list/get + payment webhook, seller
transfers, promo codes, downloads, seller stats, reviews, invoices).
Future splits should follow the same pattern : one file per cohesive
concern, sentinels co-located with the methods that use them, no
signature changes. Recommended order if continuing :
  service_orders.go         (CreateOrder + ProcessPaymentWebhook +
                              processSellerTransfers + Hyperswitch
                              webhook helpers — ~700 LOC, biggest
                              remaining cluster)
  service_seller_stats.go   (4 stats methods — ~150 LOC)
  service_reviews.go        (CreateReview + ListReviews — ~100 LOC)

Behaviour-preserving by construction. No tests changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 04:05:44 +02:00
..
admin feat(v0.11.3): F421-F424 admin platform handler and routes 2026-03-10 18:19:45 +01:00
analytics fix(v0.12.6): apply all pentest remediations — 36 findings across 36 files 2026-03-14 00:44:46 +01:00
auth feat(auth): defer JWT to post-verify + verify-email header (v1.0.9 items 1.3+1.4) 2026-04-26 22:56:31 +02:00
collaboration adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
connecterrors feat(marketplace): stripe reversal error disambiguation + CHECK constraint + E2E — v1.0.7 item B day 3 2026-04-18 02:12:03 +02:00
discover style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
distribution feat(subscription): recovery endpoint + distribution gate (v1.0.9 item G — Phase 3) 2026-04-27 11:33:40 +02:00
education style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
feed feat(v0.10.1): Tags & Genres discover - F351-F355 2026-03-09 01:52:56 +01:00
marketplace refactor(marketplace): extract refund flow into service_refunds.go 2026-05-01 04:05:44 +02:00
moderation feat(v0.11.2): F411-F420 moderation handler and routes 2026-03-10 17:49:51 +01:00
social fix(v0.12.6): apply all pentest remediations — 36 findings across 36 files 2026-03-14 00:44:46 +01:00
subscription feat(subscription): recovery endpoint + distribution gate (v1.0.9 item G — Phase 3) 2026-04-27 11:33:40 +02:00
track feat(security): pre-flight pentest scripts + share-token enumeration fix + audit doc (W5 Day 21) 2026-04-29 12:10:06 +02:00