- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core) - Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token - Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers - Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.6 KiB
Go
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
|
|
}
|