saveinmed/backend/internal/usecase/payment_config.go
Tiago Yamamoto 36d6fa4ae0 feat: Implement Phase 4 features
Backend (Go):
- FCM Push Notifications (fcm.go, push_handler.go)
- Credit Lines (credit_line.go, credit_handler.go)
- Payment Config (admin_handler.go, seller_payment_handler.go)
- Team Management (team_handler.go)

Backoffice (NestJS):
- Dashboard module (KPIs, revenue charts)
- Audit module (tracking changes)
- Disputes module (CRUD, resolution)
- Reports module (CSV export)
- Performance module (seller scores)
- Fraud module (detection, alerts)

Frontend (Marketplace):
- ThemeContext for Dark Mode
- HelpCenter page with FAQ
- OrderDetails with timeline
- Team management page
- Persistent cart (Zustand)
2025-12-27 10:07:05 -03:00

44 lines
1.6 KiB
Go

package usecase
import (
"context"
"github.com/gofrs/uuid/v5"
"github.com/saveinmed/backend-go/internal/domain"
)
// GetPaymentGatewayConfig returns the configuration for a specific provider
func (s *Service) GetPaymentGatewayConfig(ctx context.Context, provider string) (*domain.PaymentGatewayConfig, error) {
return s.repo.GetPaymentGatewayConfig(ctx, provider)
}
// UpsertPaymentGatewayConfig updates global gateway configuration
func (s *Service) UpsertPaymentGatewayConfig(ctx context.Context, config *domain.PaymentGatewayConfig) error {
// Logic to encrypt credentials could go here
return s.repo.UpsertPaymentGatewayConfig(ctx, config)
}
// GetSellerPaymentAccount returns a seller's connected account details
func (s *Service) GetSellerPaymentAccount(ctx context.Context, sellerID uuid.UUID) (*domain.SellerPaymentAccount, error) {
return s.repo.GetSellerPaymentAccount(ctx, sellerID)
}
// OnboardSeller initiates the onboarding process for a seller (e.g. Stripe Connect)
func (s *Service) OnboardSeller(ctx context.Context, sellerID uuid.UUID, gateway string) (string, error) {
// 1. Generate Connect Link (Mock for now or call gateway)
// For MVP, just return a dummy link and create pending record
// Real implementation would use s.pay.CreateConnectLink(...)
// Ensure record exists
account := &domain.SellerPaymentAccount{
SellerID: sellerID,
Gateway: gateway,
Status: "pending",
AccountType: "standard", // default
}
if err := s.repo.UpsertSellerPaymentAccount(ctx, account); err != nil {
return "", err
}
return "https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_123&scope=read_write", nil
}