payments.go
package payments
import (
"github.com/readysite/readysite/hosting/internal/websites"
"github.com/readysite/readysite/hosting/models"
)
// Plan represents a billing plan.
type Plan struct {
ID string // "free" or "pro"
Name string
Price int // cents per month
}
var (
FreePlan = Plan{ID: "free", Name: "Free", Price: 0}
ProPlan = Plan{ID: "pro", Name: "Pro", Price: 0}
)
// UpgradeSite upgrades a site to Pro by recreating its container with a
// persistent database volume. Synchronous — container recreate is fast.
func UpgradeSite(site *models.Site) error {
if err := websites.Upgrade(site); err != nil {
return err
}
site.Plan = "pro"
site.Status = "active"
return models.Sites.Update(site)
}