2
0
Files
gitcaddy-server/services/forms/monetize_form.go
logikonline d1f20f6b46
All checks were successful
Build and Release / Create Release (push) Successful in 0s
Build and Release / Unit Tests (push) Successful in 3m10s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 5m13s
Build and Release / Lint (push) Successful in 5m25s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 3m13s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Successful in 8h5m42s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 7m30s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Successful in 7m55s
Build and Release / Build Binary (linux/arm64) (push) Successful in 7m36s
feat(ci): add repository subscription monetization system
Implement complete subscription monetization system for repositories with Stripe and PayPal integration. Includes:
- Database models and migrations for monetization settings, subscription products, and user subscriptions
- Payment provider abstraction layer with Stripe and PayPal implementations
- Admin UI for configuring payment providers and viewing subscriptions
- Repository settings UI for managing subscription products and tiers
- Subscription checkout flow and webhook handlers for payment events
- Access control to gate repository code behind active subscriptions
2026-01-31 13:37:07 -05:00

48 lines
1.5 KiB
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
package forms
import (
"net/http"
"code.gitcaddy.com/server/v3/modules/web/middleware"
"code.gitcaddy.com/server/v3/services/context"
"gitea.com/go-chi/binding"
)
// MonetizeSettingsForm is the admin form for configuring payment providers.
type MonetizeSettingsForm struct {
StripeEnabled bool
StripeSecretKey string `binding:"MaxSize(255)"`
StripePublishableKey string `binding:"MaxSize(255)"`
StripeWebhookSecret string `binding:"MaxSize(255)"`
PayPalEnabled bool
PayPalClientID string `binding:"MaxSize(255)"`
PayPalClientSecret string `binding:"MaxSize(255)"`
PayPalWebhookID string `binding:"MaxSize(255)"`
PayPalSandbox bool
}
// Validate validates the fields
func (f *MonetizeSettingsForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
ctx := context.GetValidateContext(req)
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}
// SubscriptionProductForm is the repo settings form for creating/editing products.
type SubscriptionProductForm struct {
Name string `binding:"Required;MaxSize(255)"`
Type int `binding:"Required;Range(1,3)"`
PriceCents int64 `binding:"Required;Min(1)"`
Currency string `binding:"Required;MaxSize(3)"`
IsActive bool
}
// Validate validates the fields
func (f *SubscriptionProductForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
ctx := context.GetValidateContext(req)
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}