implement core foundation
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user