# Plan d'implémentation v0.403 — Phase 4 Commerce (suite) **Version cible** : v0.403 **Objectif** : Payout vendeurs, reviews produits, factures, remboursements **Référence** : [V0_403_RELEASE_SCOPE.md](V0_403_RELEASE_SCOPE.md) **Dernière mise à jour** : février 2026 --- ## Diagramme de dépendances v0.403 ```mermaid flowchart TD subgraph Backend [veza-backend-api] R1_B[R1 Migration product_reviews + routes] F1_B[F1 Génération PDF facture] R2_B[R2 Refund API + webhook] P3_B[P3 Stripe Connect payout] end subgraph Frontend [apps/web] R1_F[ProductDetailView reviews ProductCard rating] F1_F[PurchasesView lien facture] R2_F[SellerDashboardView bouton refund] P3_F[SellerDashboardView balance onboarding] end R1_B --> R1_F F1_B --> F1_F R2_B --> R2_F P3_B --> P3_F ``` --- ## Phase 0 — Vérification préalable | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 0.1 | Vérifier numérotation migrations (101+ libre) | `veza-backend-api/migrations/` | — | | 0.2 | Vérifier routes marketplace/sell actuelles | `routes_marketplace.go`, sell handlers | — | | 0.3 | Vérifier Hyperswitch/Stripe refund API | Doc Hyperswitch | — | | 0.4 | Vérifier ProductDetailView, PurchasesView, SellerDashboardView | `apps/web/src/` | — | --- ## Phase 1 — Lot R1 (Reviews produits) | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 1.1 | Migration product_reviews | `migrations/101_product_reviews.sql` | `feat(marketplace): add product_reviews migration` | | 1.2 | Modèle ProductReview, service | `marketplace/models.go`, `service.go` | `feat(marketplace): add ProductReview model` | | 1.3 | POST /marketplace/products/:id/reviews | Handler, vérifier license | `feat(marketplace): add create review endpoint` | | 1.4 | GET /marketplace/products/:id/reviews | Handler paginé | `feat(marketplace): add list reviews endpoint` | | 1.5 | Note moyenne sur Product | Préchargement ou computed | `feat(marketplace): add avg_rating to Product` | | 1.6 | marketplaceService createReview, listReviews | `marketplaceService.ts` | `feat(marketplace): add review API to frontend` | | 1.7 | ProductDetailView : formulaire avis, liste avis | `ProductDetailView.tsx` | `feat(marketplace): add reviews UI to ProductDetailView` | | 1.8 | ProductCard : badge note moyenne | `ProductCard.tsx` | `feat(marketplace): add rating badge to ProductCard` | **Validation** : Achat → avis créé → affiché, note moyenne mise à jour. --- ## Phase 2 — Lot F1 (Factures) | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 2.1 | Dépendance lib PDF (gopdf, gofpdf) | `go.mod` | `chore(backend): add PDF library` | | 2.2 | Service GenerateInvoice | `marketplace/service.go` | `feat(marketplace): add invoice generation` | | 2.3 | GET /marketplace/orders/:id/invoice | Handler, PDF response | `feat(marketplace): add invoice download endpoint` | | 2.4 | marketplaceService getInvoiceUrl | `marketplaceService.ts` | `feat(marketplace): add invoice download to frontend` | | 2.5 | PurchasesView / LicensesView : lien « Télécharger facture » | Composants | `feat(marketplace): add invoice download link` | **Validation** : Commande complétée → téléchargement PDF facture. --- ## Phase 3 — Lot R2 (Remboursements) | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 3.1 | Service RefundOrder | `marketplace/service.go` | `feat(marketplace): add refund order logic` | | 3.2 | POST /marketplace/orders/:id/refund | Handler (seller/admin) | `feat(marketplace): add refund endpoint` | | 3.3 | Webhook refund (si Hyperswitch fournit) | ProcessWebhook | `feat(marketplace): handle refund webhook` | | 3.4 | Révocation licence sur refund | Service | `feat(marketplace): revoke license on refund` | | 3.5 | SellerDashboardView : bouton Rembourser sur vente | `SellerDashboardView.tsx` | `feat(seller): add refund button to sales` | **Validation** : Remboursement initié → order refunded, licence révoquée. --- ## Phase 4 — Lot P3 (Payout vendeurs) | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 4.1 | Config Stripe Connect (client_id, keys) | `config.go` | `feat(seller): add Stripe Connect config` | | 4.2 | POST /sell/connect/onboard | Redirect Stripe Express | `feat(seller): add Connect onboarding endpoint` | | 4.3 | GET /sell/balance | Balance depuis Stripe ou table | `feat(seller): add balance endpoint` | | 4.4 | SellerDashboardView : carte balance, bouton onboarding | `SellerDashboardView.tsx` | `feat(seller): add balance and onboarding UI` | | 4.5 | Transfert après vente (optionnel) | Webhook ou post-create order | `feat(seller): add payout on sale` | **Validation** : Vendeur onboarding → balance affichée. Option : report P3 si Stripe Connect non configuré. --- ## Phase 5 — Finalisation | # | Tâche | Fichiers | Commit suggéré | |---|-------|----------|----------------| | 5.1 | MSW handlers (reviews, invoice, refund, balance) | `handlers-marketplace.ts` | `test(marketplace): add MSW handlers for v0.403` | | 5.2 | Stories Storybook (composants nouveaux) | Composants | `feat(marketplace): add stories for v0.403` | | 5.3 | CHANGELOG v0.403 | `CHANGELOG.md` | `docs: update CHANGELOG for v0.403` | | 5.4 | FEATURE_STATUS, PROJECT_STATE | `docs/` | `docs: update docs for v0.403 release` | --- ## Ordre d'exécution recommandé 1. **Phase 0** — Vérification (30 min) 2. **Phase 1** — R1 Reviews (3-4 j) 3. **Phase 2** — F1 Factures (2-3 j) 4. **Phase 3** — R2 Remboursements (2-3 j) 5. **Phase 4** — P3 Payout (5-7 j, ou report) 6. **Phase 5** — Finalisation (0.5-1 j) --- ## Références - [V0_403_RELEASE_SCOPE.md](V0_403_RELEASE_SCOPE.md) — Scope détaillé - [veza-backend-api/internal/core/marketplace/](../veza-backend-api/internal/core/marketplace/) — Service marketplace - [apps/web/src/components/seller/](../apps/web/src/components/seller/) — Composants seller - [STORYBOOK_CONTRACT.md](../apps/web/docs/STORYBOOK_CONTRACT.md) — Contrat Storybook