67826b92c0
* implement core foundation * inject deps * fix incorrect migration * tail migration * use transaction for migration * fix: inject deps for tests * cleanup billing management for admin * upgrade stripe sdk to v85 * set price env variables * cleanup billing management * allow multiple dev windows * fix: settings scroll * feat: show nice video thumbnail in listview * feat: implement freemium restrictions * remove unnecessary comments * refactor * docs * format * tweak network settings better hierarchy
38 lines
723 B
Go
38 lines
723 B
Go
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
|
|
}
|