package billing

import (
	"fmt"
	"strings"
)

type Config struct {
	SecretKey      string
	WebhookSecret  string
	PriceMonthlyID string
	PriceAnnualID  string

	SuccessURL string
	CancelURL  string
}

func (c Config) Validate() error {
	required := map[string]string{
		"SecretKey":      c.SecretKey,
		"WebhookSecret":  c.WebhookSecret,
		"PriceMonthlyID": c.PriceMonthlyID,
		"PriceAnnualID":  c.PriceAnnualID,
		"SuccessURL":     c.SuccessURL,
		"CancelURL":      c.CancelURL,
	}
	var missing []string
	for name, value := range required {
		if value == "" {
			missing = append(missing, name)
		}
	}
	if len(missing) > 0 {
		return fmt.Errorf("billing config missing: %s", strings.Join(missing, ", "))
	}
	return nil
}
