veza/veza-backend-api/internal/core/marketplace
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
..
cart.go chore(release): v0.602 — Payout, Dette Technique & Tests E2E 2026-02-23 22:32:01 +01:00
invoice.go chore(backend): add PDF library for invoices 2026-02-22 16:11:42 +01:00
invoice_test.go v0.9.4 2026-03-05 23:03:43 +01:00
models.go feat(stream): HLS default on + marketplace 30s pre-listen + FLAC tier checkbox (W4 Day 17) 2026-04-29 09:56:02 +02:00
payout.go refactor(connect): persist stripe_transfer_id on create + retry — v1.0.7 item A 2026-04-17 13:08:39 +02:00
payout_test.go style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
process_webhook_test.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
reconcile_hyperswitch.go feat(metrics): ledger-health gauges + alert rules — v1.0.7 item F 2026-04-18 03:40:14 +02:00
reconcile_hyperswitch_test.go fix(ci): unblock CI red — gofmt + e2e webserver reuse + orders.hyperswitch_payment_id (Day 4) 2026-04-27 12:03:55 +02:00
refund_test.go fix(hyperswitch): idempotency-key on create-payment and create-refund — v1.0.7 item D 2026-04-18 02:30:02 +02:00
reversal_e2e_test.go feat(marketplace): stripe reversal error disambiguation + CHECK constraint + E2E — v1.0.7 item B day 3 2026-04-18 02:12:03 +02:00
reversal_worker.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
reversal_worker_test.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
review_test.go v0.9.4 2026-03-05 23:03:43 +01:00
service.go refactor(marketplace): extract refund flow into service_refunds.go 2026-05-01 04:05:44 +02:00
service_refunds.go refactor(marketplace): extract refund flow into service_refunds.go 2026-05-01 04:05:44 +02:00
transfer_retry.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
transfer_retry_test.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
transfer_transitions.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
transfer_transitions_test.go feat(marketplace): async stripe connect reversal worker — v1.0.7 item B day 2 2026-04-17 15:34:29 +02:00
wishlist.go feat(backend): add social groups, wishlist, cart, and playlist export endpoints 2026-02-12 22:48:50 +01:00