Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: in-app subscription purchase for SaaS workspaces (BYT-9094) (#19749)

ecmadao910c7ae1ea8b
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 885377c103..2b7984b153 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -5969,6 +5969,116 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Sheet'
+ /bytebase.v1.SubscriptionService/CancelPurchase:
+ post:
+ tags:
+ - bytebase.v1.SubscriptionService
+ summary: CancelPurchase
+ description: CancelPurchase cancels an active subscription (SaaS only).
+ operationId: bytebase.v1.SubscriptionService.CancelPurchase
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CancelPurchaseRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CancelPurchaseResponse'
+ /bytebase.v1.SubscriptionService/CreatePurchase:
+ post:
+ tags:
+ - bytebase.v1.SubscriptionService
+ summary: CreatePurchase
+ description: |-
+ CreatePurchase creates a new subscription purchase (SaaS only).
+ Returns a Stripe Checkout URL for the user to complete payment.
+ operationId: bytebase.v1.SubscriptionService.CreatePurchase
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CreatePurchaseRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CreatePurchaseResponse'
+ /bytebase.v1.SubscriptionService/GetPaymentInfo:
+ post:
+ tags:
+ - bytebase.v1.SubscriptionService
+ summary: GetPaymentInfo
+ description: GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ operationId: bytebase.v1.SubscriptionService.GetPaymentInfo
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.GetPaymentInfoRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.PaymentInfo'
/bytebase.v1.SubscriptionService/GetSubscription:
post:
tags:
@@ -6009,13 +6119,87 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Subscription'
+ /bytebase.v1.SubscriptionService/ListPurchasePlans:
+ post:
+ tags:
+ - bytebase.v1.SubscriptionService
+ summary: ListPurchasePlans
+ description: ListPurchasePlans returns available plans for self-service purchase.
+ operationId: bytebase.v1.SubscriptionService.ListPurchasePlans
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.ListPurchasePlansRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.ListPurchasePlansResponse'
+ /bytebase.v1.SubscriptionService/UpdatePurchase:
+ post:
+ tags:
+ - bytebase.v1.SubscriptionService
+ summary: UpdatePurchase
+ description: |-
+ UpdatePurchase updates an existing subscription (SaaS only).
+ May return a Stripe Checkout URL if payment method change is needed.
+ operationId: bytebase.v1.SubscriptionService.UpdatePurchase
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.UpdatePurchaseRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.UpdatePurchaseResponse'
/bytebase.v1.SubscriptionService/UpdateSubscription:
post:
tags:
- bytebase.v1.SubscriptionService
summary: UpdateSubscription
description: |-
- Updates the enterprise license subscription.
+ Updates the enterprise license subscription (self-hosted only).
Permissions required: bb.settings.set
operationId: bytebase.v1.SubscriptionService.UpdateSubscription
parameters:
@@ -8560,6 +8744,13 @@ components:
title: worksheet_organizers
title: BatchUpdateWorksheetOrganizerResponse
additionalProperties: false
+ bytebase.v1.BillingInterval:
+ type: string
+ title: BillingInterval
+ enum:
+ - BILLING_INTERVAL_UNSPECIFIED
+ - MONTH
+ - YEAR
bytebase.v1.Binding:
type: object
properties:
@@ -8681,6 +8872,14 @@ components:
type: object
title: CancelPlanCheckRunResponse
additionalProperties: false
+ bytebase.v1.CancelPurchaseRequest:
+ type: object
+ title: CancelPurchaseRequest
+ additionalProperties: false
+ bytebase.v1.CancelPurchaseResponse:
+ type: object
+ title: CancelPurchaseResponse
+ additionalProperties: false
bytebase.v1.Changelog:
type: object
properties:
@@ -9173,6 +9372,30 @@ components:
are /[a-z][0-9]-/.
title: CreateProjectRequest
additionalProperties: false
+ bytebase.v1.CreatePurchaseRequest:
+ type: object
+ properties:
+ plan:
+ title: plan
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ seats:
+ type: integer
+ title: seats
+ format: int32
+ title: CreatePurchaseRequest
+ additionalProperties: false
+ bytebase.v1.CreatePurchaseResponse:
+ type: object
+ properties:
+ paymentUrl:
+ type: string
+ title: payment_url
+ description: Stripe Checkout URL for the user to complete payment.
+ title: CreatePurchaseResponse
+ additionalProperties: false
bytebase.v1.CreateReleaseRequest:
type: object
properties:
@@ -11102,6 +11325,10 @@ components:
description: If set to true, bypass cache and fetch the latest data.
title: GetIssueRequest
additionalProperties: false
+ bytebase.v1.GetPaymentInfoRequest:
+ type: object
+ title: GetPaymentInfoRequest
+ additionalProperties: false
bytebase.v1.GetPlanCheckRunRequest:
type: object
properties:
@@ -13039,6 +13266,20 @@ components:
If this field is omitted, there are no subsequent pages.
title: ListProjectsResponse
additionalProperties: false
+ bytebase.v1.ListPurchasePlansRequest:
+ type: object
+ title: ListPurchasePlansRequest
+ additionalProperties: false
+ bytebase.v1.ListPurchasePlansResponse:
+ type: object
+ properties:
+ plans:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlan'
+ title: plans
+ title: ListPurchasePlansResponse
+ additionalProperties: false
bytebase.v1.ListReleaseCategoriesRequest:
type: object
properties:
@@ -13996,6 +14237,27 @@ components:
title: PackageMetadata
additionalProperties: false
description: PackageMetadata is the metadata for packages.
+ bytebase.v1.PaymentInfo:
+ type: object
+ properties:
+ totalPrice:
+ type: string
+ title: total_price
+ currency:
+ type: string
+ title: currency
+ periodStart:
+ type: string
+ title: period_start
+ periodEnd:
+ type: string
+ title: period_end
+ invoiceUrl:
+ type: string
+ title: invoice_url
+ description: Stripe Billing Portal URL for invoice management.
+ title: PaymentInfo
+ additionalProperties: false
bytebase.v1.PermissionDeniedDetail:
type: object
properties:
@@ -14794,6 +15056,81 @@ components:
title: value
title: LabelsEntry
additionalProperties: false
+ bytebase.v1.PurchaseBillingMethod:
+ type: object
+ properties:
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ discount:
+ title: discount
+ $ref: '#/components/schemas/bytebase.v1.PurchaseDiscount'
+ title: PurchaseBillingMethod
+ additionalProperties: false
+ bytebase.v1.PurchaseDiscount:
+ type: object
+ properties:
+ description:
+ type: string
+ title: description
+ promotionCode:
+ type: string
+ title: promotion_code
+ title: PurchaseDiscount
+ additionalProperties: false
+ bytebase.v1.PurchasePlan:
+ type: object
+ properties:
+ type:
+ title: type
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ selfServicePurchase:
+ type: boolean
+ title: self_service_purchase
+ additionals:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlanAdditional'
+ title: additionals
+ billingMethods:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchaseBillingMethod'
+ title: billing_methods
+ title: PurchasePlan
+ additionalProperties: false
+ bytebase.v1.PurchasePlanAdditional:
+ type: object
+ properties:
+ type:
+ title: type
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlanAdditional.Type'
+ unitPrice:
+ type: integer
+ title: unit_price
+ format: int32
+ description: Price in USD cents per month.
+ freeCount:
+ type: integer
+ title: free_count
+ format: int32
+ minimumCount:
+ type: integer
+ title: minimum_count
+ format: int32
+ maximumCount:
+ type: integer
+ title: maximum_count
+ format: int32
+ description: -1 means unlimited.
+ title: PurchasePlanAdditional
+ additionalProperties: false
+ bytebase.v1.PurchasePlanAdditional.Type:
+ type: string
+ title: Type
+ enum:
+ - TYPE_UNSPECIFIED
+ - USER
bytebase.v1.QueryDataPolicy:
type: object
properties:
@@ -18730,6 +19067,35 @@ components:
In this situation, `update_mask` is ignored.
title: UpdateProjectRequest
additionalProperties: false
+ bytebase.v1.UpdatePurchaseRequest:
+ type: object
+ properties:
+ plan:
+ title: plan
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ seats:
+ type: integer
+ title: seats
+ format: int32
+ etag:
+ type: string
+ title: etag
+ title: UpdatePurchaseRequest
+ additionalProperties: false
+ bytebase.v1.UpdatePurchaseResponse:
+ type: object
+ properties:
+ paymentUrl:
+ type: string
+ title: payment_url
+ description: |-
+ If set, redirect to this Stripe Checkout URL.
+ If empty, the update was applied directly using the existing payment method.
+ title: UpdatePurchaseResponse
+ additionalProperties: false
bytebase.v1.UpdateReleaseRequest:
type: object
properties:
@@ -20667,8 +21033,6 @@ components:
documentation for additional information.
security: []
tags:
- - name: bytebase.v1.SubscriptionService
- description: SubscriptionService manages enterprise subscriptions and licensing.
- name: bytebase.v1.AccessGrantService
description: AccessGrantService manages temporary access grants within projects.
- name: bytebase.v1.IssueService
@@ -20723,6 +21087,8 @@ tags:
description: ServiceAccountService manages service accounts for API integrations.
- name: bytebase.v1.SheetService
description: SheetService manages SQL scripts and saved queries.
+ - name: bytebase.v1.SubscriptionService
+ description: SubscriptionService manages enterprise subscriptions and licensing.
- name: bytebase.v1.WorkloadIdentityService
description: WorkloadIdentityService manages workload identities for external CI/CD integrations.
- name: bytebase.v1.WorksheetService
diff --git a/backend/api/stripe/webhook.go b/backend/api/stripe/webhook.go
new file mode 100644
index 0000000000..c37cd40d10
--- /dev/null
+++ b/backend/api/stripe/webhook.go
@@ -0,0 +1,287 @@
+// Package stripe handles Stripe webhook callbacks for SaaS subscription management.
+package stripe
+
+import (
+ "context"
+ "encoding/json"
+ "io"
+ "log/slog"
+ "net/http"
+ "strconv"
+ "time"
+
+ "github.com/labstack/echo/v5"
+ "github.com/pkg/errors"
+ stripego "github.com/stripe/stripe-go/v82"
+ "github.com/stripe/stripe-go/v82/customer"
+ "github.com/stripe/stripe-go/v82/webhook"
+ "google.golang.org/protobuf/types/known/timestamppb"
+
+ "github.com/bytebase/bytebase/backend/common/log"
+ "github.com/bytebase/bytebase/backend/enterprise"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ stripeplugin "github.com/bytebase/bytebase/backend/plugin/stripe"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+// WebhookHandler handles Stripe webhook events.
+type WebhookHandler struct {
+ store *store.Store
+ licenseService *enterprise.LicenseService
+ webhookSecret string
+}
+
+// NewWebhookHandler creates a new WebhookHandler.
+func NewWebhookHandler(store *store.Store, licenseService *enterprise.LicenseService, webhookSecret string) *WebhookHandler {
+ return &WebhookHandler{
+ store: store,
+ licenseService: licenseService,
+ webhookSecret: webhookSecret,
+ }
+}
+
+// RegisterRoutes registers the Stripe webhook route.
+func (h *WebhookHandler) RegisterRoutes(g *echo.Group) {
+ g.POST("/callback", h.handleCallback)
+}
+
+func (h *WebhookHandler) handleCallback(c *echo.Context) error {
+ ctx := c.Request().Context()
+ body, err := io.ReadAll(c.Request().Body)
+ if err != nil {
+ return c.String(http.StatusBadRequest, "failed to read request body")
+ }
+
+ sig := c.Request().Header.Get("Stripe-Signature")
+ event, err := webhook.ConstructEvent(body, sig, h.webhookSecret)
+ if err != nil {
+ slog.Error("stripe webhook signature verification failed", log.BBError(err))
+ return c.String(http.StatusBadRequest, "invalid signature")
+ }
+
+ if err := h.processEvent(ctx, &event); err != nil {
+ slog.Error("failed to process stripe webhook event",
+ log.BBError(err),
+ slog.String("type", string(event.Type)),
+ slog.String("id", event.ID),
+ )
+ return c.JSON(http.StatusInternalServerError, map[string]string{"status": "error"})
+ }
+
+ return c.JSON(http.StatusOK, map[string]string{"status": "success"})
+}
+
+func (h *WebhookHandler) processEvent(ctx context.Context, event *stripego.Event) error {
+ switch event.Type {
+ case
+ "customer.subscription.created",
+ "customer.subscription.updated",
+ "customer.subscription.deleted",
+ "customer.subscription.paused",
+ "customer.subscription.resumed":
+ return h.handleSubscriptionStatusChange(ctx, event)
+ case "invoice.paid":
+ return h.handleInvoicePaid(ctx, event)
+ default:
+ return nil
+ }
+}
+
+func (h *WebhookHandler) handleSubscriptionStatusChange(ctx context.Context, event *stripego.Event) error {
+ var sub stripego.Subscription
+ if err := json.Unmarshal(event.Data.Raw, &sub); err != nil {
+ return errors.Wrap(err, "failed to unmarshal subscription")
+ }
+
+ if sub.Metadata["source"] != stripeplugin.WebhookSource {
+ return nil
+ }
+
+ workspace := sub.Metadata["workspace"]
+ if workspace == "" {
+ slog.Error("missing workspace in stripe subscription metadata",
+ slog.String("stripe_subscription_id", sub.ID),
+ slog.String("event_type", string(event.Type)),
+ )
+ return nil
+ }
+
+ status, err := mapStripeStatus(sub.Status)
+ if err != nil {
+ return err
+ }
+
+ stripeCustomer, err := getStripeCustomer(sub.Customer)
+ if err != nil {
+ return err
+ }
+
+ slog.Info("stripe subscription status changed",
+ slog.String("event_type", string(event.Type)),
+ slog.String("workspace", workspace),
+ slog.String("stripe_subscription_id", sub.ID),
+ slog.String("stripe_status", string(sub.Status)),
+ slog.String("mapped_status", status.String()),
+ )
+
+ existing, err := h.store.GetSubscriptionByWorkspace(ctx, workspace)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get subscription for workspace %s", workspace)
+ }
+ if existing == nil {
+ slog.Error("no subscription found for workspace", slog.String("workspace", workspace))
+ return nil
+ }
+
+ payload := existing.Payload
+ payload.Status = status
+ payload.StripeSubscriptionId = sub.ID
+ payload.StripeCustomerId = stripeCustomer.ID
+
+ if event.Type == "customer.subscription.created" && len(sub.Items.Data) > 0 {
+ expiresAt := time.Unix(sub.Items.Data[0].CurrentPeriodEnd, 0).UTC()
+ payload.ExpiresAt = timestamppb.New(expiresAt)
+ }
+
+ if _, err := h.store.UpdateSubscription(ctx, workspace, payload); err != nil {
+ return errors.Wrapf(err, "failed to update subscription for workspace %s", workspace)
+ }
+
+ h.licenseService.InvalidateCache(workspace)
+ return nil
+}
+
+func (h *WebhookHandler) handleInvoicePaid(ctx context.Context, event *stripego.Event) error {
+ var inv stripego.Invoice
+ if err := json.Unmarshal(event.Data.Raw, &inv); err != nil {
+ return errors.Wrap(err, "failed to unmarshal invoice")
+ }
+
+ if len(inv.Lines.Data) == 0 {
+ return errors.Errorf("invoice %s has no line items", inv.ID)
+ }
+
+ metadata := inv.Lines.Data[0].Metadata
+ if metadata["source"] != stripeplugin.WebhookSource {
+ return nil
+ }
+
+ workspace := metadata["workspace"]
+ if workspace == "" {
+ slog.Error("missing workspace in invoice metadata", slog.String("invoice_id", inv.ID))
+ return nil
+ }
+
+ stripeCustomer, err := getStripeCustomer(inv.Customer)
+ if err != nil {
+ return err
+ }
+
+ // Parse metadata fields.
+ plan, err := parsePlan(metadata["plan"])
+ if err != nil {
+ return err
+ }
+ interval, err := parseInterval(metadata["interval"])
+ if err != nil {
+ return err
+ }
+ instanceCount, err := strconv.Atoi(metadata["instance_count"])
+ if err != nil {
+ return errors.Wrapf(err, "failed to parse instance_count %q", metadata["instance_count"])
+ }
+ userCount, err := strconv.Atoi(metadata["user_count"])
+ if err != nil {
+ return errors.Wrapf(err, "failed to parse user_count %q", metadata["user_count"])
+ }
+
+ // Get Stripe subscription ID from invoice parent.
+ var stripeSubID string
+ if inv.Parent != nil && inv.Parent.SubscriptionDetails != nil && inv.Parent.SubscriptionDetails.Subscription != nil {
+ stripeSubID = inv.Parent.SubscriptionDetails.Subscription.ID
+ }
+
+ lineData := inv.Lines.Data[0]
+ startedAt := time.Unix(lineData.Period.Start, 0).UTC()
+ expiresAt := time.Unix(lineData.Period.End, 0).UTC()
+
+ slog.Info("stripe invoice paid",
+ slog.String("workspace", workspace),
+ slog.String("stripe_subscription_id", stripeSubID),
+ slog.String("plan", plan.String()),
+ slog.Int("seats", userCount),
+ slog.Int("instances", instanceCount),
+ slog.Time("started_at", startedAt),
+ slog.Time("expires_at", expiresAt),
+ )
+
+ existing, err := h.store.GetSubscriptionByWorkspace(ctx, workspace)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get subscription for workspace %s", workspace)
+ }
+ if existing == nil {
+ return errors.Errorf("no subscription found for workspace %s", workspace)
+ }
+
+ payload := &storepb.SubscriptionPayload{
+ Status: storepb.SubscriptionPayload_ACTIVE,
+ StartedAt: timestamppb.New(startedAt),
+ ExpiresAt: timestamppb.New(expiresAt),
+ Plan: plan,
+ Interval: interval,
+ Seat: int32(userCount),
+ InstanceCount: int32(instanceCount),
+ StripeSubscriptionId: stripeSubID,
+ StripeCustomerId: stripeCustomer.ID,
+ }
+
+ if _, err := h.store.UpdateSubscription(ctx, workspace, payload); err != nil {
+ return errors.Wrapf(err, "failed to update subscription for workspace %s", workspace)
+ }
+
+ h.licenseService.InvalidateCache(workspace)
+ return nil
+}
+
+func mapStripeStatus(status stripego.SubscriptionStatus) (storepb.SubscriptionPayload_Status, error) {
+ switch status {
+ case stripego.SubscriptionStatusActive, stripego.SubscriptionStatusTrialing:
+ return storepb.SubscriptionPayload_ACTIVE, nil
+ case stripego.SubscriptionStatusCanceled:
+ return storepb.SubscriptionPayload_CANCELED, nil
+ case stripego.SubscriptionStatusPastDue, stripego.SubscriptionStatusUnpaid,
+ stripego.SubscriptionStatusPaused, stripego.SubscriptionStatusIncomplete,
+ stripego.SubscriptionStatusIncompleteExpired:
+ return storepb.SubscriptionPayload_PAUSED, nil
+ default:
+ return storepb.SubscriptionPayload_STATUS_UNSPECIFIED, errors.Errorf("unsupported stripe subscription status %v", status)
+ }
+}
+
+func parsePlan(s string) (storepb.SubscriptionPayload_Plan, error) {
+ v, ok := storepb.SubscriptionPayload_Plan_value[s]
+ if !ok {
+ return storepb.SubscriptionPayload_PLAN_UNSPECIFIED, errors.Errorf("unknown plan %q", s)
+ }
+ return storepb.SubscriptionPayload_Plan(v), nil
+}
+
+func parseInterval(s string) (storepb.SubscriptionPayload_BillingInterval, error) {
+ v, ok := storepb.SubscriptionPayload_BillingInterval_value[s]
+ if !ok {
+ return storepb.SubscriptionPayload_BILLING_INTERVAL_UNSPECIFIED, errors.Errorf("unknown interval %q", s)
+ }
+ return storepb.SubscriptionPayload_BillingInterval(v), nil
+}
+
+// getStripeCustomer gets the full customer object.
+// Stripe webhooks may only include the customer ID, not the full object.
+func getStripeCustomer(c *stripego.Customer) (*stripego.Customer, error) {
+ if c == nil {
+ return nil, errors.New("empty customer field")
+ }
+ if c.ID != "" && c.Email != "" {
+ return c, nil
+ }
+ return customer.Get(c.ID, nil)
+}
diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.go
index a512372e57..006b43ea29 100644
--- a/backend/api/v1/subscription_service.go
+++ b/backend/api/v1/subscription_service.go
@@ -2,44 +2,60 @@ package v1
import (
"context"
+ "fmt"
+ "log/slog"
+ "strconv"
+ "time"
"connectrpc.com/connect"
"github.com/pkg/errors"
+ "google.golang.org/protobuf/types/known/timestamppb"
"github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/enterprise"
+ "github.com/bytebase/bytebase/backend/enterprise/pricing"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
+ stripeplugin "github.com/bytebase/bytebase/backend/plugin/stripe"
+ "github.com/bytebase/bytebase/backend/store"
)
// SubscriptionService implements the subscription service.
type SubscriptionService struct {
v1connect.UnimplementedSubscriptionServiceHandler
profile *config.Profile
+ store *store.Store
licenseService *enterprise.LicenseService
}
// NewSubscriptionService creates a new SubscriptionService.
func NewSubscriptionService(
profile *config.Profile,
- licenseService *enterprise.LicenseService) *SubscriptionService {
+ stores *store.Store,
+ licenseService *enterprise.LicenseService,
+) *SubscriptionService {
return &SubscriptionService{
profile: profile,
+ store: stores,
licenseService: licenseService,
}
}
// GetSubscription gets the subscription.
-// allow_without_credential: if no workspace in context, falls back to free subscription.
func (s *SubscriptionService) GetSubscription(ctx context.Context, _ *connect.Request[v1pb.GetSubscriptionRequest]) (*connect.Response[v1pb.Subscription], error) {
subscription := s.licenseService.LoadSubscription(ctx, common.GetWorkspaceIDFromContext(ctx))
return connect.NewResponse(subscription), nil
}
-// UpdateSubscription updates the subscription license.
+// UpdateSubscription updates the subscription license (self-hosted only).
func (s *SubscriptionService) UpdateSubscription(ctx context.Context, req *connect.Request[v1pb.UpdateSubscriptionRequest]) (*connect.Response[v1pb.Subscription], error) {
- // TODO(ed): disable UpdateSubscription once we support purchase license in SaaS V2
+ if s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("use purchase APIs in SaaS mode"))
+ }
+
if err := s.licenseService.StoreLicense(ctx, common.GetWorkspaceIDFromContext(ctx), req.Msg.License); err != nil {
if common.ErrorCode(err) == common.Invalid {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
@@ -50,3 +66,362 @@ func (s *SubscriptionService) UpdateSubscription(ctx context.Context, req *conne
subscription := s.licenseService.LoadSubscription(ctx, common.GetWorkspaceIDFromContext(ctx))
return connect.NewResponse(subscription), nil
}
+
+// CreatePurchase creates a new subscription purchase (SaaS only).
+func (s *SubscriptionService) CreatePurchase(ctx context.Context, req *connect.Request[v1pb.CreatePurchaseRequest]) (*connect.Response[v1pb.CreatePurchaseResponse], error) {
+ if !s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("purchase is only available in SaaS mode"))
+ }
+
+ workspaceID := common.GetWorkspaceIDFromContext(ctx)
+
+ // Check no existing active subscription.
+ existing, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get subscription"))
+ }
+ if existing != nil && existing.Payload != nil && existing.Payload.Status == storepb.SubscriptionPayload_ACTIVE {
+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.New("workspace already has an active subscription"))
+ }
+
+ plan, interval, seats := convertV1PlanToStore(req.Msg.Plan), convertV1IntervalToStore(req.Msg.Interval), req.Msg.Seats
+ priceModel, err := pricing.NewPriceModel(plan, interval, seats)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
+
+ planLimit := pricing.GetPlanLimit(plan)
+
+ // Create or update subscription record with PENDING status.
+ payload := &storepb.SubscriptionPayload{
+ Status: storepb.SubscriptionPayload_PENDING,
+ Plan: plan,
+ Interval: interval,
+ Seat: seats,
+ InstanceCount: planLimit.InstanceCount,
+ StartedAt: timestamppb.Now(),
+ ExpiresAt: timestamppb.Now(),
+ }
+
+ if existing != nil {
+ if _, err := s.store.UpdateSubscription(ctx, workspaceID, payload); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to update subscription"))
+ }
+ } else {
+ if _, err := s.store.CreateSubscription(ctx, &store.SubscriptionMessage{
+ Workspace: workspaceID,
+ Payload: payload,
+ }); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to create subscription"))
+ }
+ }
+
+ // Generate Stripe Checkout URL.
+ redirectURL := fmt.Sprintf("%s/setting/subscription", s.profile.ExternalURL)
+ paymentURL, err := stripeplugin.CreateCheckoutSession(&stripeplugin.CheckoutParams{
+ Workspace: workspaceID,
+ PriceModel: priceModel,
+ SuccessURL: fmt.Sprintf("%s?from=STRIPE", redirectURL),
+ CancelURL: redirectURL,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to create checkout session"))
+ }
+
+ return connect.NewResponse(&v1pb.CreatePurchaseResponse{
+ PaymentUrl: paymentURL,
+ }), nil
+}
+
+// UpdatePurchase updates an existing subscription (SaaS only).
+func (s *SubscriptionService) UpdatePurchase(ctx context.Context, req *connect.Request[v1pb.UpdatePurchaseRequest]) (*connect.Response[v1pb.UpdatePurchaseResponse], error) {
+ if !s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("purchase is only available in SaaS mode"))
+ }
+
+ workspaceID := common.GetWorkspaceIDFromContext(ctx)
+
+ existing, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get subscription"))
+ }
+ if existing == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.New("no subscription found"))
+ }
+ if req.Msg.Etag != "" && req.Msg.Etag != existing.Etag {
+ return nil, connect.NewError(connect.CodeAborted, errors.New("subscription is out of date, please refresh and try again"))
+ }
+
+ plan, interval, seats := convertV1PlanToStore(req.Msg.Plan), convertV1IntervalToStore(req.Msg.Interval), req.Msg.Seats
+ priceModel, err := pricing.NewPriceModel(plan, interval, seats)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
+
+ planLimit := pricing.GetPlanLimit(plan)
+
+ // If subscription is not active (PENDING/CANCELED), reset to PENDING and generate new checkout URL.
+ if existing.Payload == nil || existing.Payload.Status != storepb.SubscriptionPayload_ACTIVE {
+ payload := &storepb.SubscriptionPayload{
+ Status: storepb.SubscriptionPayload_PENDING,
+ Plan: plan,
+ Interval: interval,
+ Seat: seats,
+ InstanceCount: planLimit.InstanceCount,
+ StartedAt: timestamppb.Now(),
+ ExpiresAt: timestamppb.Now(),
+ }
+ if _, err := s.store.UpdateSubscription(ctx, workspaceID, payload); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to update subscription"))
+ }
+
+ redirectURL := fmt.Sprintf("%s/setting/subscription", s.profile.ExternalURL)
+ paymentURL, err := stripeplugin.CreateCheckoutSession(&stripeplugin.CheckoutParams{
+ Workspace: workspaceID,
+ PriceModel: priceModel,
+ SuccessURL: fmt.Sprintf("%s?from=STRIPE", redirectURL),
+ CancelURL: redirectURL,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to create checkout session"))
+ }
+ return connect.NewResponse(&v1pb.UpdatePurchaseResponse{PaymentUrl: paymentURL}), nil
+ }
+
+ // Active subscription — cancel old Stripe subscription and create new one.
+ oldPayload := existing.Payload
+ if oldPayload.StripeSubscriptionId == "" {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New("no Stripe subscription to update"))
+ }
+
+ // Clear metadata on old subscription so webhook ignores the cancel event.
+ metadata := stripeplugin.GetMetadata(workspaceID, priceModel)
+ metadata["workspace"] = ""
+ if err := stripeplugin.UpdateSubscriptionMetadata(oldPayload.StripeSubscriptionId, metadata); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to clear old subscription metadata"))
+ }
+
+ // Cancel old subscription with forced refund.
+ if _, err := stripeplugin.CancelSubscription(oldPayload.StripeSubscriptionId, workspaceID, true); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to cancel old subscription"))
+ }
+
+ // Try to create new Stripe subscription directly using existing payment method.
+ oldStripeSub, err := stripeplugin.GetSubscription(oldPayload.StripeSubscriptionId, []string{"default_payment_method", "customer"})
+ if err != nil {
+ slog.Error("failed to get old stripe subscription, falling back to checkout",
+ log.BBError(err),
+ slog.String("workspace", workspaceID),
+ )
+ return s.fallbackToCheckout(ctx, workspaceID, priceModel, plan, interval, seats, planLimit.InstanceCount)
+ }
+
+ customerID := oldStripeSub.Customer.ID
+ if customerID == "" {
+ return s.fallbackToCheckout(ctx, workspaceID, priceModel, plan, interval, seats, planLimit.InstanceCount)
+ }
+
+ var paymentMethodID string
+ if oldStripeSub.DefaultPaymentMethod != nil {
+ paymentMethodID = oldStripeSub.DefaultPaymentMethod.ID
+ }
+
+ newSub, err := stripeplugin.CreateSubscriptionDirect(&stripeplugin.DirectSubscriptionParams{
+ CustomerID: customerID,
+ PaymentMethodID: paymentMethodID,
+ PriceModel: priceModel,
+ Metadata: stripeplugin.GetMetadata(workspaceID, priceModel),
+ })
+ if err != nil {
+ slog.Error("failed to create new stripe subscription directly, falling back to checkout",
+ log.BBError(err),
+ slog.String("workspace", workspaceID),
+ )
+ return s.fallbackToCheckout(ctx, workspaceID, priceModel, plan, interval, seats, planLimit.InstanceCount)
+ }
+
+ slog.Info("created new stripe subscription for plan change",
+ slog.String("workspace", workspaceID),
+ slog.String("old_stripe_sub", oldPayload.StripeSubscriptionId),
+ slog.String("new_stripe_sub", newSub.ID),
+ )
+
+ return connect.NewResponse(&v1pb.UpdatePurchaseResponse{}), nil
+}
+
+func (s *SubscriptionService) fallbackToCheckout(
+ ctx context.Context,
+ workspaceID string,
+ priceModel *pricing.PriceModel,
+ plan storepb.SubscriptionPayload_Plan,
+ interval storepb.SubscriptionPayload_BillingInterval,
+ seats int32,
+ instanceCount int32,
+) (*connect.Response[v1pb.UpdatePurchaseResponse], error) {
+ payload := &storepb.SubscriptionPayload{
+ Status: storepb.SubscriptionPayload_PENDING,
+ Plan: plan,
+ Interval: interval,
+ Seat: seats,
+ InstanceCount: instanceCount,
+ StartedAt: timestamppb.Now(),
+ ExpiresAt: timestamppb.Now(),
+ }
+ if _, err := s.store.UpdateSubscription(ctx, workspaceID, payload); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to update subscription"))
+ }
+
+ redirectURL := fmt.Sprintf("%s/setting/subscription", s.profile.ExternalURL)
+ paymentURL, err := stripeplugin.CreateCheckoutSession(&stripeplugin.CheckoutParams{
+ Workspace: workspaceID,
+ PriceModel: priceModel,
+ SuccessURL: fmt.Sprintf("%s?from=STRIPE", redirectURL),
+ CancelURL: redirectURL,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to create checkout session"))
+ }
+ return connect.NewResponse(&v1pb.UpdatePurchaseResponse{PaymentUrl: paymentURL}), nil
+}
+
+// CancelPurchase cancels an active subscription (SaaS only).
+func (s *SubscriptionService) CancelPurchase(ctx context.Context, _ *connect.Request[v1pb.CancelPurchaseRequest]) (*connect.Response[v1pb.CancelPurchaseResponse], error) {
+ if !s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("purchase is only available in SaaS mode"))
+ }
+
+ workspaceID := common.GetWorkspaceIDFromContext(ctx)
+
+ existing, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get subscription"))
+ }
+ if existing == nil || existing.Payload == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.New("no subscription found"))
+ }
+
+ payload := existing.Payload
+ if payload.StripeSubscriptionId == "" {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New("no Stripe subscription to cancel"))
+ }
+
+ // Monthly: immediate cancel with proration + refund.
+ // Annual: cancel at period end.
+ prorate := payload.Interval == storepb.SubscriptionPayload_MONTH
+ if _, err := stripeplugin.CancelSubscription(payload.StripeSubscriptionId, workspaceID, prorate); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to cancel subscription"))
+ }
+
+ // Update status. For prorated (monthly), set CANCELED + expire immediately.
+ // For annual, the webhook will update the status when Stripe cancels at period end.
+ if prorate {
+ payload.Status = storepb.SubscriptionPayload_CANCELED
+ payload.ExpiresAt = timestamppb.New(time.Now().Add(-time.Second))
+ if _, err := s.store.UpdateSubscription(ctx, workspaceID, payload); err != nil {
+ slog.Error("failed to update subscription after cancellation", log.BBError(err))
+ }
+ s.licenseService.InvalidateCache(workspaceID)
+ }
+
+ return connect.NewResponse(&v1pb.CancelPurchaseResponse{}), nil
+}
+
+// GetPaymentInfo returns payment details (SaaS only).
+func (s *SubscriptionService) GetPaymentInfo(ctx context.Context, _ *connect.Request[v1pb.GetPaymentInfoRequest]) (*connect.Response[v1pb.PaymentInfo], error) {
+ if !s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("purchase is only available in SaaS mode"))
+ }
+
+ workspaceID := common.GetWorkspaceIDFromContext(ctx)
+
+ existing, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get subscription"))
+ }
+ if existing == nil || existing.Payload == nil || existing.Payload.StripeSubscriptionId == "" {
+ return nil, connect.NewError(connect.CodeNotFound, errors.New("no subscription found"))
+ }
+
+ payload := existing.Payload
+ sub, err := stripeplugin.GetSubscription(payload.StripeSubscriptionId, nil)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get stripe subscription"))
+ }
+
+ inv, err := stripeplugin.FindLastPaidInvoice(sub)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get invoice"))
+ }
+
+ period := inv.Lines.Data[0].Period
+ info := &v1pb.PaymentInfo{
+ TotalPrice: strconv.FormatInt(inv.Total, 10),
+ Currency: string(sub.Currency),
+ PeriodStart: time.Unix(period.Start, 0).Format("2006-01-02"),
+ PeriodEnd: time.Unix(period.End, 0).Format("2006-01-02"),
+ }
+
+ // Create billing portal session for invoice management.
+ if payload.StripeCustomerId != "" {
+ returnURL := fmt.Sprintf("%s/setting/subscription", s.profile.ExternalURL)
+ portalURL, err := stripeplugin.CreateBillingPortalSession(payload.StripeCustomerId, returnURL)
+ if err != nil {
+ slog.Error("failed to create billing portal session", log.BBError(err))
+ } else {
+ info.InvoiceUrl = portalURL
+ }
+ }
+
+ return connect.NewResponse(info), nil
+}
+
+// ListPurchasePlans returns available plans for self-service purchase.
+func (*SubscriptionService) ListPurchasePlans(_ context.Context, _ *connect.Request[v1pb.ListPurchasePlansRequest]) (*connect.Response[v1pb.ListPurchasePlansResponse], error) {
+ plans := []*v1pb.PurchasePlan{
+ {
+ Type: v1pb.PlanType_TEAM,
+ SelfServicePurchase: true,
+ Additionals: []*v1pb.PurchasePlanAdditional{
+ {
+ Type: v1pb.PurchasePlanAdditional_USER,
+ UnitPrice: 2000, // $20/user/month
+ FreeCount: 0,
+ MinimumCount: 1,
+ MaximumCount: -1, // unlimited
+ },
+ },
+ BillingMethods: []*v1pb.PurchaseBillingMethod{
+ {Interval: v1pb.BillingInterval_MONTH},
+ {Interval: v1pb.BillingInterval_YEAR},
+ },
+ },
+ {
+ Type: v1pb.PlanType_ENTERPRISE,
+ SelfServicePurchase: false,
+ },
+ }
+
+ return connect.NewResponse(&v1pb.ListPurchasePlansResponse{Plans: plans}), nil
+}
+
+func convertV1PlanToStore(plan v1pb.PlanType) storepb.SubscriptionPayload_Plan {
+ switch plan {
+ case v1pb.PlanType_TEAM:
+ return storepb.SubscriptionPayload_TEAM
+ case v1pb.PlanType_ENTERPRISE:
+ return storepb.SubscriptionPayload_ENTERPRISE
+ default:
+ return storepb.SubscriptionPayload_PLAN_UNSPECIFIED
+ }
+}
+
+func convertV1IntervalToStore(interval v1pb.BillingInterval) storepb.SubscriptionPayload_BillingInterval {
+ switch interval {
+ case v1pb.BillingInterval_MONTH:
+ return storepb.SubscriptionPayload_MONTH
+ case v1pb.BillingInterval_YEAR:
+ return storepb.SubscriptionPayload_YEAR
+ default:
+ return storepb.SubscriptionPayload_BILLING_INTERVAL_UNSPECIFIED
+ }
+}
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.go
index e72f8b88f0..ff5c1137c2 100644
--- a/backend/bin/server/cmd/profile.go
+++ b/backend/bin/server/cmd/profile.go
@@ -11,19 +11,21 @@ import (
func getBaseProfile(dataDir string) *config.Profile {
config := &config.Profile{
- ExternalURL: flags.externalURL,
- Port: flags.port, // Using flags.port as our gRPC server port.
- DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.
- HA: flags.ha,
- SaaS: flags.saas,
- Debug: flags.debug,
- IsDocker: isDocker(),
- DataDir: dataDir,
- Demo: flags.demo,
- Version: version,
- GitCommit: gitcommit,
- PgURL: os.Getenv("PG_URL"),
- ReplicaID: uuid.NewString(),
+ ExternalURL: flags.externalURL,
+ Port: flags.port, // Using flags.port as our gRPC server port.
+ DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.
+ HA: flags.ha,
+ SaaS: flags.saas,
+ Debug: flags.debug,
+ IsDocker: isDocker(),
+ DataDir: dataDir,
+ Demo: flags.demo,
+ Version: version,
+ GitCommit: gitcommit,
+ PgURL: os.Getenv("PG_URL"),
+ ReplicaID: uuid.NewString(),
+ StripeAPIKey: os.Getenv("STRIPE_API_KEY"),
+ StripeWebhookSecret: os.Getenv("STRIPE_WEBHOOK_SECRET"),
}
config.LastActiveTS.Store(time.Now().Unix())
diff --git a/backend/common/permission/permission.go b/backend/common/permission/permission.go
index f11cb2b5a4..fb6af251b1 100644
--- a/backend/common/permission/permission.go
+++ b/backend/common/permission/permission.go
@@ -111,6 +111,7 @@ const (
ServiceAccountsList Permission = "bb.serviceAccounts.list"
ServiceAccountsUndelete Permission = "bb.serviceAccounts.undelete"
ServiceAccountsUpdate Permission = "bb.serviceAccounts.update"
+ SubscriptionManage Permission = "bb.subscription.manage"
SettingsGet Permission = "bb.settings.get"
SettingsList Permission = "bb.settings.list"
SettingsSet Permission = "bb.settings.set"
diff --git a/backend/common/permission/permission.yaml b/backend/common/permission/permission.yaml
index 57b76ff0d2..86066cb46b 100644
--- a/backend/common/permission/permission.yaml
+++ b/backend/common/permission/permission.yaml
@@ -113,6 +113,7 @@ permissions:
- bb.sheets.create
- bb.sheets.get
- bb.sheets.update
+ - bb.subscription.manage
- bb.sql.select
- bb.sql.ddl
- bb.sql.dml
diff --git a/backend/component/config/profile.go b/backend/component/config/profile.go
index 6180ecdbd3..aa4ebf7a42 100644
--- a/backend/component/config/profile.go
+++ b/backend/component/config/profile.go
@@ -21,6 +21,9 @@ type Profile struct {
Port int
// When we are running in SaaS mode, some features are not allowed to edit by users.
SaaS bool
+ // Stripe configuration for SaaS subscription purchase. Only used when SaaS is true.
+ StripeAPIKey string
+ StripeWebhookSecret string
// DataDir is the directory stores the data including Bytebase's own database, backups, etc.
DataDir string
// Demo mode.
diff --git a/backend/enterprise/license.go b/backend/enterprise/license.go
index d31949f7be..41a7b8c1d7 100644
--- a/backend/enterprise/license.go
+++ b/backend/enterprise/license.go
@@ -24,6 +24,7 @@ import (
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/store"
)
@@ -198,7 +199,13 @@ func (s *LicenseService) LoadSubscription(ctx context.Context, workspaceID strin
return sub, nil
}
- subscription := s.loadSubscriptionFromDB(ctx, workspaceID)
+ var subscription *v1pb.Subscription
+ // TODO(ed): find if be able to unify this
+ if s.saas {
+ subscription = s.loadSubscriptionFromPurchase(ctx, workspaceID)
+ } else {
+ subscription = s.loadSubscriptionFromDB(ctx, workspaceID)
+ }
// Only cache non-free subscriptions. Free plan may be a transient failure
// (e.g. DB not ready during startup), and caching it would mask the real
@@ -252,6 +259,53 @@ func (s *LicenseService) loadSubscriptionFromDB(ctx context.Context, workspaceID
return subscription
}
+// loadSubscriptionFromPurchase loads subscription from the subscription table (SaaS mode).
+func (s *LicenseService) loadSubscriptionFromPurchase(ctx context.Context, workspaceID string) *v1pb.Subscription {
+ sub, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ slog.Debug("failed to get subscription from purchase table", log.BBError(err))
+ return defaultFreeSubscription
+ }
+ if sub == nil || sub.Payload == nil {
+ return defaultFreeSubscription
+ }
+
+ payload := sub.Payload
+ if payload.Status != storepb.SubscriptionPayload_ACTIVE {
+ return defaultFreeSubscription
+ }
+
+ subscription := &v1pb.Subscription{
+ Plan: convertStorePlanToV1(payload.Plan),
+ Seats: payload.Seat,
+ Instances: payload.InstanceCount,
+ ActiveInstances: payload.InstanceCount,
+ }
+ if payload.ExpiresAt != nil {
+ subscription.ExpiresTime = payload.ExpiresAt
+ }
+
+ if isExpired(subscription) {
+ return &v1pb.Subscription{
+ Plan: v1pb.PlanType_FREE,
+ ExpiresTime: subscription.ExpiresTime,
+ }
+ }
+
+ return subscription
+}
+
+func convertStorePlanToV1(plan storepb.SubscriptionPayload_Plan) v1pb.PlanType {
+ switch plan {
+ case storepb.SubscriptionPayload_TEAM:
+ return v1pb.PlanType_TEAM
+ case storepb.SubscriptionPayload_ENTERPRISE:
+ return v1pb.PlanType_ENTERPRISE
+ default:
+ return v1pb.PlanType_FREE
+ }
+}
+
func isExpired(sub *v1pb.Subscription) bool {
if sub == nil {
return false
@@ -362,6 +416,12 @@ func (s *LicenseService) StoreLicense(ctx context.Context, workspaceID string, l
return nil
}
+// InvalidateCache removes the cached subscription for a workspace,
+// forcing the next LoadSubscription call to reload from the database.
+func (s *LicenseService) InvalidateCache(workspaceID string) {
+ s.cache.Remove(licenseCacheKey(workspaceID))
+}
+
// GetAuditLogRetentionDays returns the audit log retention period in days for the current plan.
// Returns:
// - 0: No access (FREE plan)
diff --git a/backend/generated-go/v1/subscription_service.pb.go b/backend/generated-go/v1/subscription_service.pb.go
index a7d7cf3d48..ac752ea0d0 100644
--- a/backend/generated-go/v1/subscription_service.pb.go
+++ b/backend/generated-go/v1/subscription_service.pb.go
@@ -23,6 +23,55 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
+type BillingInterval int32
+
+const (
+ BillingInterval_BILLING_INTERVAL_UNSPECIFIED BillingInterval = 0
+ BillingInterval_MONTH BillingInterval = 1
+ BillingInterval_YEAR BillingInterval = 2
+)
+
+// Enum value maps for BillingInterval.
+var (
+ BillingInterval_name = map[int32]string{
+ 0: "BILLING_INTERVAL_UNSPECIFIED",
+ 1: "MONTH",
+ 2: "YEAR",
+ }
+ BillingInterval_value = map[string]int32{
+ "BILLING_INTERVAL_UNSPECIFIED": 0,
+ "MONTH": 1,
+ "YEAR": 2,
+ }
+)
+
+func (x BillingInterval) Enum() *BillingInterval {
+ p := new(BillingInterval)
+ *p = x
+ return p
+}
+
+func (x BillingInterval) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (BillingInterval) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_subscription_service_proto_enumTypes[0].Descriptor()
+}
+
+func (BillingInterval) Type() protoreflect.EnumType {
+ return &file_v1_subscription_service_proto_enumTypes[0]
+}
+
+func (x BillingInterval) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use BillingInterval.Descriptor instead.
+func (BillingInterval) EnumDescriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{0}
+}
+
type PlanType int32
const (
@@ -63,11 +112,11 @@ func (x PlanType) String() string {
}
func (PlanType) Descriptor() protoreflect.EnumDescriptor {
- return file_v1_subscription_service_proto_enumTypes[0].Descriptor()
+ return file_v1_subscription_service_proto_enumTypes[1].Descriptor()
}
func (PlanType) Type() protoreflect.EnumType {
- return &file_v1_subscription_service_proto_enumTypes[0]
+ return &file_v1_subscription_service_proto_enumTypes[1]
}
func (x PlanType) Number() protoreflect.EnumNumber {
@@ -76,7 +125,7 @@ func (x PlanType) Number() protoreflect.EnumNumber {
// Deprecated: Use PlanType.Descriptor instead.
func (PlanType) EnumDescriptor() ([]byte, []int) {
- return file_v1_subscription_service_proto_rawDescGZIP(), []int{0}
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{1}
}
// PlanFeature represents the available features in Bytebase
@@ -324,11 +373,11 @@ func (x PlanFeature) String() string {
}
func (PlanFeature) Descriptor() protoreflect.EnumDescriptor {
- return file_v1_subscription_service_proto_enumTypes[1].Descriptor()
+ return file_v1_subscription_service_proto_enumTypes[2].Descriptor()
}
func (PlanFeature) Type() protoreflect.EnumType {
- return &file_v1_subscription_service_proto_enumTypes[1]
+ return &file_v1_subscription_service_proto_enumTypes[2]
}
func (x PlanFeature) Number() protoreflect.EnumNumber {
@@ -337,7 +386,53 @@ func (x PlanFeature) Number() protoreflect.EnumNumber {
// Deprecated: Use PlanFeature.Descriptor instead.
func (PlanFeature) EnumDescriptor() ([]byte, []int) {
- return file_v1_subscription_service_proto_rawDescGZIP(), []int{1}
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{2}
+}
+
+type PurchasePlanAdditional_Type int32
+
+const (
+ PurchasePlanAdditional_TYPE_UNSPECIFIED PurchasePlanAdditional_Type = 0
+ PurchasePlanAdditional_USER PurchasePlanAdditional_Type = 1
+)
+
+// Enum value maps for PurchasePlanAdditional_Type.
+var (
+ PurchasePlanAdditional_Type_name = map[int32]string{
+ 0: "TYPE_UNSPECIFIED",
+ 1: "USER",
+ }
+ PurchasePlanAdditional_Type_value = map[string]int32{
+ "TYPE_UNSPECIFIED": 0,
+ "USER": 1,
+ }
+)
+
+func (x PurchasePlanAdditional_Type) Enum() *PurchasePlanAdditional_Type {
+ p := new(PurchasePlanAdditional_Type)
+ *p = x
+ return p
+}
+
+func (x PurchasePlanAdditional_Type) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (PurchasePlanAdditional_Type) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_subscription_service_proto_enumTypes[3].Descriptor()
+}
+
+func (PurchasePlanAdditional_Type) Type() protoreflect.EnumType {
+ return &file_v1_subscription_service_proto_enumTypes[3]
+}
+
+func (x PurchasePlanAdditional_Type) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use PurchasePlanAdditional_Type.Descriptor instead.
+func (PurchasePlanAdditional_Type) EnumDescriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{11, 0}
}
type GetSubscriptionRequest struct {
@@ -430,35 +525,29 @@ func (x *UpdateSubscriptionRequest) GetAllowMissing() bool {
return false
}
-type Subscription struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Plan PlanType `protobuf:"varint,1,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
- Seats int32 `protobuf:"varint,2,opt,name=seats,proto3" json:"seats,omitempty"`
- Instances int32 `protobuf:"varint,3,opt,name=instances,proto3" json:"instances,omitempty"`
- ActiveInstances int32 `protobuf:"varint,4,opt,name=active_instances,json=activeInstances,proto3" json:"active_instances,omitempty"`
- ExpiresTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=expires_time,json=expiresTime,proto3" json:"expires_time,omitempty"`
- Trialing bool `protobuf:"varint,6,opt,name=trialing,proto3" json:"trialing,omitempty"`
- OrgName string `protobuf:"bytes,7,opt,name=org_name,json=orgName,proto3" json:"org_name,omitempty"`
- // Whether high availability (multiple replicas) is enabled.
- Ha bool `protobuf:"varint,8,opt,name=ha,proto3" json:"ha,omitempty"`
+type CreatePurchaseRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Plan PlanType `protobuf:"varint,1,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
+ Interval BillingInterval `protobuf:"varint,2,opt,name=interval,proto3,enum=bytebase.v1.BillingInterval" json:"interval,omitempty"`
+ Seats int32 `protobuf:"varint,3,opt,name=seats,proto3" json:"seats,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
-func (x *Subscription) Reset() {
- *x = Subscription{}
+func (x *CreatePurchaseRequest) Reset() {
+ *x = CreatePurchaseRequest{}
mi := &file_v1_subscription_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *Subscription) String() string {
+func (x *CreatePurchaseRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*Subscription) ProtoMessage() {}
+func (*CreatePurchaseRequest) ProtoMessage() {}
-func (x *Subscription) ProtoReflect() protoreflect.Message {
+func (x *CreatePurchaseRequest) ProtoReflect() protoreflect.Message {
mi := &file_v1_subscription_service_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -470,91 +559,102 @@ func (x *Subscription) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use Subscription.ProtoReflect.Descriptor instead.
-func (*Subscription) Descriptor() ([]byte, []int) {
+// Deprecated: Use CreatePurchaseRequest.ProtoReflect.Descriptor instead.
+func (*CreatePurchaseRequest) Descriptor() ([]byte, []int) {
return file_v1_subscription_service_proto_rawDescGZIP(), []int{2}
}
-func (x *Subscription) GetPlan() PlanType {
+func (x *CreatePurchaseRequest) GetPlan() PlanType {
if x != nil {
return x.Plan
}
return PlanType_PLAN_TYPE_UNSPECIFIED
}
-func (x *Subscription) GetSeats() int32 {
+func (x *CreatePurchaseRequest) GetInterval() BillingInterval {
if x != nil {
- return x.Seats
+ return x.Interval
}
- return 0
+ return BillingInterval_BILLING_INTERVAL_UNSPECIFIED
}
-func (x *Subscription) GetInstances() int32 {
+func (x *CreatePurchaseRequest) GetSeats() int32 {
if x != nil {
- return x.Instances
+ return x.Seats
}
return 0
}
-func (x *Subscription) GetActiveInstances() int32 {
- if x != nil {
- return x.ActiveInstances
- }
- return 0
+type CreatePurchaseResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Stripe Checkout URL for the user to complete payment.
+ PaymentUrl string `protobuf:"bytes,1,opt,name=payment_url,json=paymentUrl,proto3" json:"payment_url,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
-func (x *Subscription) GetExpiresTime() *timestamppb.Timestamp {
- if x != nil {
- return x.ExpiresTime
- }
- return nil
+func (x *CreatePurchaseResponse) Reset() {
+ *x = CreatePurchaseResponse{}
+ mi := &file_v1_subscription_service_proto_msgTypes[3]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
}
-func (x *Subscription) GetTrialing() bool {
- if x != nil {
- return x.Trialing
- }
- return false
+func (x *CreatePurchaseResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
}
-func (x *Subscription) GetOrgName() string {
+func (*CreatePurchaseResponse) ProtoMessage() {}
+
+func (x *CreatePurchaseResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[3]
if x != nil {
- return x.OrgName
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
}
- return ""
+ return mi.MessageOf(x)
}
-func (x *Subscription) GetHa() bool {
+// Deprecated: Use CreatePurchaseResponse.ProtoReflect.Descriptor instead.
+func (*CreatePurchaseResponse) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *CreatePurchaseResponse) GetPaymentUrl() string {
if x != nil {
- return x.Ha
+ return x.PaymentUrl
}
- return false
+ return ""
}
-// PlanConfig represents the configuration for all plans loaded from plan.yaml
-type PlanConfig struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Plans []*PlanLimitConfig `protobuf:"bytes,1,rep,name=plans,proto3" json:"plans,omitempty"`
- InstanceFeatures []PlanFeature `protobuf:"varint,2,rep,packed,name=instance_features,json=instanceFeatures,proto3,enum=bytebase.v1.PlanFeature" json:"instance_features,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+type UpdatePurchaseRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Plan PlanType `protobuf:"varint,1,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
+ Interval BillingInterval `protobuf:"varint,2,opt,name=interval,proto3,enum=bytebase.v1.BillingInterval" json:"interval,omitempty"`
+ Seats int32 `protobuf:"varint,3,opt,name=seats,proto3" json:"seats,omitempty"`
+ Etag string `protobuf:"bytes,4,opt,name=etag,proto3" json:"etag,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
-func (x *PlanConfig) Reset() {
- *x = PlanConfig{}
- mi := &file_v1_subscription_service_proto_msgTypes[3]
+func (x *UpdatePurchaseRequest) Reset() {
+ *x = UpdatePurchaseRequest{}
+ mi := &file_v1_subscription_service_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *PlanConfig) String() string {
+func (x *UpdatePurchaseRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*PlanConfig) ProtoMessage() {}
+func (*UpdatePurchaseRequest) ProtoMessage() {}
-func (x *PlanConfig) ProtoReflect() protoreflect.Message {
- mi := &file_v1_subscription_service_proto_msgTypes[3]
+func (x *UpdatePurchaseRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -565,51 +665,63 @@ func (x *PlanConfig) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use PlanConfig.ProtoReflect.Descriptor instead.
-func (*PlanConfig) Descriptor() ([]byte, []int) {
- return file_v1_subscription_service_proto_rawDescGZIP(), []int{3}
+// Deprecated: Use UpdatePurchaseRequest.ProtoReflect.Descriptor instead.
+func (*UpdatePurchaseRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{4}
}
-func (x *PlanConfig) GetPlans() []*PlanLimitConfig {
+func (x *UpdatePurchaseRequest) GetPlan() PlanType {
if x != nil {
- return x.Plans
+ return x.Plan
}
- return nil
+ return PlanType_PLAN_TYPE_UNSPECIFIED
}
-func (x *PlanConfig) GetInstanceFeatures() []PlanFeature {
+func (x *UpdatePurchaseRequest) GetInterval() BillingInterval {
if x != nil {
- return x.InstanceFeatures
+ return x.Interval
}
- return nil
+ return BillingInterval_BILLING_INTERVAL_UNSPECIFIED
}
-// PlanLimitConfig represents a single plan's configuration
-type PlanLimitConfig struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Type PlanType `protobuf:"varint,1,opt,name=type,proto3,enum=bytebase.v1.PlanType" json:"type,omitempty"`
- MaximumInstanceCount int32 `protobuf:"varint,2,opt,name=maximum_instance_count,json=maximumInstanceCount,proto3" json:"maximum_instance_count,omitempty"`
- MaximumSeatCount int32 `protobuf:"varint,3,opt,name=maximum_seat_count,json=maximumSeatCount,proto3" json:"maximum_seat_count,omitempty"`
- Features []PlanFeature `protobuf:"varint,4,rep,packed,name=features,proto3,enum=bytebase.v1.PlanFeature" json:"features,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+func (x *UpdatePurchaseRequest) GetSeats() int32 {
+ if x != nil {
+ return x.Seats
+ }
+ return 0
}
-func (x *PlanLimitConfig) Reset() {
- *x = PlanLimitConfig{}
- mi := &file_v1_subscription_service_proto_msgTypes[4]
+func (x *UpdatePurchaseRequest) GetEtag() string {
+ if x != nil {
+ return x.Etag
+ }
+ return ""
+}
+
+type UpdatePurchaseResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // If set, redirect to this Stripe Checkout URL.
+ // If empty, the update was applied directly using the existing payment method.
+ PaymentUrl string `protobuf:"bytes,1,opt,name=payment_url,json=paymentUrl,proto3" json:"payment_url,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *UpdatePurchaseResponse) Reset() {
+ *x = UpdatePurchaseResponse{}
+ mi := &file_v1_subscription_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *PlanLimitConfig) String() string {
+func (x *UpdatePurchaseResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*PlanLimitConfig) ProtoMessage() {}
+func (*UpdatePurchaseResponse) ProtoMessage() {}
-func (x *PlanLimitConfig) ProtoReflect() protoreflect.Message {
- mi := &file_v1_subscription_service_proto_msgTypes[4]
+func (x *UpdatePurchaseResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -620,48 +732,817 @@ func (x *PlanLimitConfig) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use PlanLimitConfig.ProtoReflect.Descriptor instead.
-func (*PlanLimitConfig) Descriptor() ([]byte, []int) {
- return file_v1_subscription_service_proto_rawDescGZIP(), []int{4}
+// Deprecated: Use UpdatePurchaseResponse.ProtoReflect.Descriptor instead.
+func (*UpdatePurchaseResponse) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{5}
}
-func (x *PlanLimitConfig) GetType() PlanType {
+func (x *UpdatePurchaseResponse) GetPaymentUrl() string {
if x != nil {
- return x.Type
+ return x.PaymentUrl
}
- return PlanType_PLAN_TYPE_UNSPECIFIED
+ return ""
}
-func (x *PlanLimitConfig) GetMaximumInstanceCount() int32 {
- if x != nil {
- return x.MaximumInstanceCount
- }
- return 0
+type CancelPurchaseRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
-func (x *PlanLimitConfig) GetMaximumSeatCount() int32 {
+func (x *CancelPurchaseRequest) Reset() {
+ *x = CancelPurchaseRequest{}
+ mi := &file_v1_subscription_service_proto_msgTypes[6]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *CancelPurchaseRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CancelPurchaseRequest) ProtoMessage() {}
+
+func (x *CancelPurchaseRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[6]
if x != nil {
- return x.MaximumSeatCount
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
}
- return 0
+ return mi.MessageOf(x)
}
-func (x *PlanLimitConfig) GetFeatures() []PlanFeature {
+// Deprecated: Use CancelPurchaseRequest.ProtoReflect.Descriptor instead.
+func (*CancelPurchaseRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{6}
+}
+
+type CancelPurchaseResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *CancelPurchaseResponse) Reset() {
+ *x = CancelPurchaseResponse{}
+ mi := &file_v1_subscription_service_proto_msgTypes[7]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *CancelPurchaseResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CancelPurchaseResponse) ProtoMessage() {}
+
+func (x *CancelPurchaseResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[7]
if x != nil {
- return x.Features
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
}
- return nil
+ return mi.MessageOf(x)
}
-var File_v1_subscription_service_proto protoreflect.FileDescriptor
+// Deprecated: Use CancelPurchaseResponse.ProtoReflect.Descriptor instead.
+func (*CancelPurchaseResponse) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{7}
+}
-const file_v1_subscription_service_proto_rawDesc = "" +
- "\n" +
- "\x1dv1/subscription_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\"\x18\n" +
- "\x16GetSubscriptionRequest\"Z\n" +
- "\x19UpdateSubscriptionRequest\x12\x18\n" +
- "\alicense\x18\x01 \x01(\tR\alicense\x12#\n" +
- "\rallow_missing\x18\x02 \x01(\bR\fallowMissing\"\xc6\x02\n" +
+type GetPaymentInfoRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *GetPaymentInfoRequest) Reset() {
+ *x = GetPaymentInfoRequest{}
+ mi := &file_v1_subscription_service_proto_msgTypes[8]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *GetPaymentInfoRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetPaymentInfoRequest) ProtoMessage() {}
+
+func (x *GetPaymentInfoRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[8]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetPaymentInfoRequest.ProtoReflect.Descriptor instead.
+func (*GetPaymentInfoRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{8}
+}
+
+type PaymentInfo struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ TotalPrice string `protobuf:"bytes,1,opt,name=total_price,json=totalPrice,proto3" json:"total_price,omitempty"`
+ Currency string `protobuf:"bytes,2,opt,name=currency,proto3" json:"currency,omitempty"`
+ PeriodStart string `protobuf:"bytes,3,opt,name=period_start,json=periodStart,proto3" json:"period_start,omitempty"`
+ PeriodEnd string `protobuf:"bytes,4,opt,name=period_end,json=periodEnd,proto3" json:"period_end,omitempty"`
+ // Stripe Billing Portal URL for invoice management.
+ InvoiceUrl string `protobuf:"bytes,5,opt,name=invoice_url,json=invoiceUrl,proto3" json:"invoice_url,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PaymentInfo) Reset() {
+ *x = PaymentInfo{}
+ mi := &file_v1_subscription_service_proto_msgTypes[9]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PaymentInfo) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PaymentInfo) ProtoMessage() {}
+
+func (x *PaymentInfo) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[9]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PaymentInfo.ProtoReflect.Descriptor instead.
+func (*PaymentInfo) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *PaymentInfo) GetTotalPrice() string {
+ if x != nil {
+ return x.TotalPrice
+ }
+ return ""
+}
+
+func (x *PaymentInfo) GetCurrency() string {
+ if x != nil {
+ return x.Currency
+ }
+ return ""
+}
+
+func (x *PaymentInfo) GetPeriodStart() string {
+ if x != nil {
+ return x.PeriodStart
+ }
+ return ""
+}
+
+func (x *PaymentInfo) GetPeriodEnd() string {
+ if x != nil {
+ return x.PeriodEnd
+ }
+ return ""
+}
+
+func (x *PaymentInfo) GetInvoiceUrl() string {
+ if x != nil {
+ return x.InvoiceUrl
+ }
+ return ""
+}
+
+type PurchasePlan struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Type PlanType `protobuf:"varint,1,opt,name=type,proto3,enum=bytebase.v1.PlanType" json:"type,omitempty"`
+ SelfServicePurchase bool `protobuf:"varint,2,opt,name=self_service_purchase,json=selfServicePurchase,proto3" json:"self_service_purchase,omitempty"`
+ Additionals []*PurchasePlanAdditional `protobuf:"bytes,3,rep,name=additionals,proto3" json:"additionals,omitempty"`
+ BillingMethods []*PurchaseBillingMethod `protobuf:"bytes,4,rep,name=billing_methods,json=billingMethods,proto3" json:"billing_methods,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PurchasePlan) Reset() {
+ *x = PurchasePlan{}
+ mi := &file_v1_subscription_service_proto_msgTypes[10]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PurchasePlan) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchasePlan) ProtoMessage() {}
+
+func (x *PurchasePlan) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[10]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchasePlan.ProtoReflect.Descriptor instead.
+func (*PurchasePlan) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{10}
+}
+
+func (x *PurchasePlan) GetType() PlanType {
+ if x != nil {
+ return x.Type
+ }
+ return PlanType_PLAN_TYPE_UNSPECIFIED
+}
+
+func (x *PurchasePlan) GetSelfServicePurchase() bool {
+ if x != nil {
+ return x.SelfServicePurchase
+ }
+ return false
+}
+
+func (x *PurchasePlan) GetAdditionals() []*PurchasePlanAdditional {
+ if x != nil {
+ return x.Additionals
+ }
+ return nil
+}
+
+func (x *PurchasePlan) GetBillingMethods() []*PurchaseBillingMethod {
+ if x != nil {
+ return x.BillingMethods
+ }
+ return nil
+}
+
+type PurchasePlanAdditional struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Type PurchasePlanAdditional_Type `protobuf:"varint,1,opt,name=type,proto3,enum=bytebase.v1.PurchasePlanAdditional_Type" json:"type,omitempty"`
+ // Price in USD cents per month.
+ UnitPrice int32 `protobuf:"varint,2,opt,name=unit_price,json=unitPrice,proto3" json:"unit_price,omitempty"`
+ FreeCount int32 `protobuf:"varint,3,opt,name=free_count,json=freeCount,proto3" json:"free_count,omitempty"`
+ MinimumCount int32 `protobuf:"varint,4,opt,name=minimum_count,json=minimumCount,proto3" json:"minimum_count,omitempty"`
+ // -1 means unlimited.
+ MaximumCount int32 `protobuf:"varint,5,opt,name=maximum_count,json=maximumCount,proto3" json:"maximum_count,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PurchasePlanAdditional) Reset() {
+ *x = PurchasePlanAdditional{}
+ mi := &file_v1_subscription_service_proto_msgTypes[11]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PurchasePlanAdditional) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchasePlanAdditional) ProtoMessage() {}
+
+func (x *PurchasePlanAdditional) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[11]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchasePlanAdditional.ProtoReflect.Descriptor instead.
+func (*PurchasePlanAdditional) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{11}
+}
+
+func (x *PurchasePlanAdditional) GetType() PurchasePlanAdditional_Type {
+ if x != nil {
+ return x.Type
+ }
+ return PurchasePlanAdditional_TYPE_UNSPECIFIED
+}
+
+func (x *PurchasePlanAdditional) GetUnitPrice() int32 {
+ if x != nil {
+ return x.UnitPrice
+ }
+ return 0
+}
+
+func (x *PurchasePlanAdditional) GetFreeCount() int32 {
+ if x != nil {
+ return x.FreeCount
+ }
+ return 0
+}
+
+func (x *PurchasePlanAdditional) GetMinimumCount() int32 {
+ if x != nil {
+ return x.MinimumCount
+ }
+ return 0
+}
+
+func (x *PurchasePlanAdditional) GetMaximumCount() int32 {
+ if x != nil {
+ return x.MaximumCount
+ }
+ return 0
+}
+
+type PurchaseBillingMethod struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Interval BillingInterval `protobuf:"varint,1,opt,name=interval,proto3,enum=bytebase.v1.BillingInterval" json:"interval,omitempty"`
+ Discount *PurchaseDiscount `protobuf:"bytes,2,opt,name=discount,proto3" json:"discount,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PurchaseBillingMethod) Reset() {
+ *x = PurchaseBillingMethod{}
+ mi := &file_v1_subscription_service_proto_msgTypes[12]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PurchaseBillingMethod) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseBillingMethod) ProtoMessage() {}
+
+func (x *PurchaseBillingMethod) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[12]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseBillingMethod.ProtoReflect.Descriptor instead.
+func (*PurchaseBillingMethod) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{12}
+}
+
+func (x *PurchaseBillingMethod) GetInterval() BillingInterval {
+ if x != nil {
+ return x.Interval
+ }
+ return BillingInterval_BILLING_INTERVAL_UNSPECIFIED
+}
+
+func (x *PurchaseBillingMethod) GetDiscount() *PurchaseDiscount {
+ if x != nil {
+ return x.Discount
+ }
+ return nil
+}
+
+type PurchaseDiscount struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
+ PromotionCode string `protobuf:"bytes,2,opt,name=promotion_code,json=promotionCode,proto3" json:"promotion_code,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PurchaseDiscount) Reset() {
+ *x = PurchaseDiscount{}
+ mi := &file_v1_subscription_service_proto_msgTypes[13]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PurchaseDiscount) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseDiscount) ProtoMessage() {}
+
+func (x *PurchaseDiscount) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[13]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseDiscount.ProtoReflect.Descriptor instead.
+func (*PurchaseDiscount) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{13}
+}
+
+func (x *PurchaseDiscount) GetDescription() string {
+ if x != nil {
+ return x.Description
+ }
+ return ""
+}
+
+func (x *PurchaseDiscount) GetPromotionCode() string {
+ if x != nil {
+ return x.PromotionCode
+ }
+ return ""
+}
+
+type ListPurchasePlansRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ListPurchasePlansRequest) Reset() {
+ *x = ListPurchasePlansRequest{}
+ mi := &file_v1_subscription_service_proto_msgTypes[14]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ListPurchasePlansRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListPurchasePlansRequest) ProtoMessage() {}
+
+func (x *ListPurchasePlansRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[14]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ListPurchasePlansRequest.ProtoReflect.Descriptor instead.
+func (*ListPurchasePlansRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{14}
+}
+
+type ListPurchasePlansResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Plans []*PurchasePlan `protobuf:"bytes,1,rep,name=plans,proto3" json:"plans,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ListPurchasePlansResponse) Reset() {
+ *x = ListPurchasePlansResponse{}
+ mi := &file_v1_subscription_service_proto_msgTypes[15]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ListPurchasePlansResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListPurchasePlansResponse) ProtoMessage() {}
+
+func (x *ListPurchasePlansResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[15]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ListPurchasePlansResponse.ProtoReflect.Descriptor instead.
+func (*ListPurchasePlansResponse) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{15}
+}
+
+func (x *ListPurchasePlansResponse) GetPlans() []*PurchasePlan {
+ if x != nil {
+ return x.Plans
+ }
+ return nil
+}
+
+type Subscription struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Plan PlanType `protobuf:"varint,1,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
+ Seats int32 `protobuf:"varint,2,opt,name=seats,proto3" json:"seats,omitempty"`
+ Instances int32 `protobuf:"varint,3,opt,name=instances,proto3" json:"instances,omitempty"`
+ ActiveInstances int32 `protobuf:"varint,4,opt,name=active_instances,json=activeInstances,proto3" json:"active_instances,omitempty"`
+ ExpiresTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=expires_time,json=expiresTime,proto3" json:"expires_time,omitempty"`
+ Trialing bool `protobuf:"varint,6,opt,name=trialing,proto3" json:"trialing,omitempty"`
+ OrgName string `protobuf:"bytes,7,opt,name=org_name,json=orgName,proto3" json:"org_name,omitempty"`
+ // Whether high availability (multiple replicas) is enabled.
+ Ha bool `protobuf:"varint,8,opt,name=ha,proto3" json:"ha,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *Subscription) Reset() {
+ *x = Subscription{}
+ mi := &file_v1_subscription_service_proto_msgTypes[16]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *Subscription) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Subscription) ProtoMessage() {}
+
+func (x *Subscription) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[16]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use Subscription.ProtoReflect.Descriptor instead.
+func (*Subscription) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{16}
+}
+
+func (x *Subscription) GetPlan() PlanType {
+ if x != nil {
+ return x.Plan
+ }
+ return PlanType_PLAN_TYPE_UNSPECIFIED
+}
+
+func (x *Subscription) GetSeats() int32 {
+ if x != nil {
+ return x.Seats
+ }
+ return 0
+}
+
+func (x *Subscription) GetInstances() int32 {
+ if x != nil {
+ return x.Instances
+ }
+ return 0
+}
+
+func (x *Subscription) GetActiveInstances() int32 {
+ if x != nil {
+ return x.ActiveInstances
+ }
+ return 0
+}
+
+func (x *Subscription) GetExpiresTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.ExpiresTime
+ }
+ return nil
+}
+
+func (x *Subscription) GetTrialing() bool {
+ if x != nil {
+ return x.Trialing
+ }
+ return false
+}
+
+func (x *Subscription) GetOrgName() string {
+ if x != nil {
+ return x.OrgName
+ }
+ return ""
+}
+
+func (x *Subscription) GetHa() bool {
+ if x != nil {
+ return x.Ha
+ }
+ return false
+}
+
+// PlanConfig represents the configuration for all plans loaded from plan.yaml
+type PlanConfig struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Plans []*PlanLimitConfig `protobuf:"bytes,1,rep,name=plans,proto3" json:"plans,omitempty"`
+ InstanceFeatures []PlanFeature `protobuf:"varint,2,rep,packed,name=instance_features,json=instanceFeatures,proto3,enum=bytebase.v1.PlanFeature" json:"instance_features,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PlanConfig) Reset() {
+ *x = PlanConfig{}
+ mi := &file_v1_subscription_service_proto_msgTypes[17]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PlanConfig) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PlanConfig) ProtoMessage() {}
+
+func (x *PlanConfig) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[17]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PlanConfig.ProtoReflect.Descriptor instead.
+func (*PlanConfig) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{17}
+}
+
+func (x *PlanConfig) GetPlans() []*PlanLimitConfig {
+ if x != nil {
+ return x.Plans
+ }
+ return nil
+}
+
+func (x *PlanConfig) GetInstanceFeatures() []PlanFeature {
+ if x != nil {
+ return x.InstanceFeatures
+ }
+ return nil
+}
+
+// PlanLimitConfig represents a single plan's configuration
+type PlanLimitConfig struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Type PlanType `protobuf:"varint,1,opt,name=type,proto3,enum=bytebase.v1.PlanType" json:"type,omitempty"`
+ MaximumInstanceCount int32 `protobuf:"varint,2,opt,name=maximum_instance_count,json=maximumInstanceCount,proto3" json:"maximum_instance_count,omitempty"`
+ MaximumSeatCount int32 `protobuf:"varint,3,opt,name=maximum_seat_count,json=maximumSeatCount,proto3" json:"maximum_seat_count,omitempty"`
+ Features []PlanFeature `protobuf:"varint,4,rep,packed,name=features,proto3,enum=bytebase.v1.PlanFeature" json:"features,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PlanLimitConfig) Reset() {
+ *x = PlanLimitConfig{}
+ mi := &file_v1_subscription_service_proto_msgTypes[18]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PlanLimitConfig) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PlanLimitConfig) ProtoMessage() {}
+
+func (x *PlanLimitConfig) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[18]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PlanLimitConfig.ProtoReflect.Descriptor instead.
+func (*PlanLimitConfig) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{18}
+}
+
+func (x *PlanLimitConfig) GetType() PlanType {
+ if x != nil {
+ return x.Type
+ }
+ return PlanType_PLAN_TYPE_UNSPECIFIED
+}
+
+func (x *PlanLimitConfig) GetMaximumInstanceCount() int32 {
+ if x != nil {
+ return x.MaximumInstanceCount
+ }
+ return 0
+}
+
+func (x *PlanLimitConfig) GetMaximumSeatCount() int32 {
+ if x != nil {
+ return x.MaximumSeatCount
+ }
+ return 0
+}
+
+func (x *PlanLimitConfig) GetFeatures() []PlanFeature {
+ if x != nil {
+ return x.Features
+ }
+ return nil
+}
+
+var File_v1_subscription_service_proto protoreflect.FileDescriptor
+
+const file_v1_subscription_service_proto_rawDesc = "" +
+ "\n" +
+ "\x1dv1/subscription_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\"\x18\n" +
+ "\x16GetSubscriptionRequest\"Z\n" +
+ "\x19UpdateSubscriptionRequest\x12\x18\n" +
+ "\alicense\x18\x01 \x01(\tR\alicense\x12#\n" +
+ "\rallow_missing\x18\x02 \x01(\bR\fallowMissing\"\x92\x01\n" +
+ "\x15CreatePurchaseRequest\x12)\n" +
+ "\x04plan\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeR\x04plan\x128\n" +
+ "\binterval\x18\x02 \x01(\x0e2\x1c.bytebase.v1.BillingIntervalR\binterval\x12\x14\n" +
+ "\x05seats\x18\x03 \x01(\x05R\x05seats\"9\n" +
+ "\x16CreatePurchaseResponse\x12\x1f\n" +
+ "\vpayment_url\x18\x01 \x01(\tR\n" +
+ "paymentUrl\"\xa6\x01\n" +
+ "\x15UpdatePurchaseRequest\x12)\n" +
+ "\x04plan\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeR\x04plan\x128\n" +
+ "\binterval\x18\x02 \x01(\x0e2\x1c.bytebase.v1.BillingIntervalR\binterval\x12\x14\n" +
+ "\x05seats\x18\x03 \x01(\x05R\x05seats\x12\x12\n" +
+ "\x04etag\x18\x04 \x01(\tR\x04etag\"9\n" +
+ "\x16UpdatePurchaseResponse\x12\x1f\n" +
+ "\vpayment_url\x18\x01 \x01(\tR\n" +
+ "paymentUrl\"\x17\n" +
+ "\x15CancelPurchaseRequest\"\x18\n" +
+ "\x16CancelPurchaseResponse\"\x17\n" +
+ "\x15GetPaymentInfoRequest\"\xad\x01\n" +
+ "\vPaymentInfo\x12\x1f\n" +
+ "\vtotal_price\x18\x01 \x01(\tR\n" +
+ "totalPrice\x12\x1a\n" +
+ "\bcurrency\x18\x02 \x01(\tR\bcurrency\x12!\n" +
+ "\fperiod_start\x18\x03 \x01(\tR\vperiodStart\x12\x1d\n" +
+ "\n" +
+ "period_end\x18\x04 \x01(\tR\tperiodEnd\x12\x1f\n" +
+ "\vinvoice_url\x18\x05 \x01(\tR\n" +
+ "invoiceUrl\"\x81\x02\n" +
+ "\fPurchasePlan\x12)\n" +
+ "\x04type\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeR\x04type\x122\n" +
+ "\x15self_service_purchase\x18\x02 \x01(\bR\x13selfServicePurchase\x12E\n" +
+ "\vadditionals\x18\x03 \x03(\v2#.bytebase.v1.PurchasePlanAdditionalR\vadditionals\x12K\n" +
+ "\x0fbilling_methods\x18\x04 \x03(\v2\".bytebase.v1.PurchaseBillingMethodR\x0ebillingMethods\"\x86\x02\n" +
+ "\x16PurchasePlanAdditional\x12<\n" +
+ "\x04type\x18\x01 \x01(\x0e2(.bytebase.v1.PurchasePlanAdditional.TypeR\x04type\x12\x1d\n" +
+ "\n" +
+ "unit_price\x18\x02 \x01(\x05R\tunitPrice\x12\x1d\n" +
+ "\n" +
+ "free_count\x18\x03 \x01(\x05R\tfreeCount\x12#\n" +
+ "\rminimum_count\x18\x04 \x01(\x05R\fminimumCount\x12#\n" +
+ "\rmaximum_count\x18\x05 \x01(\x05R\fmaximumCount\"&\n" +
+ "\x04Type\x12\x14\n" +
+ "\x10TYPE_UNSPECIFIED\x10\x00\x12\b\n" +
+ "\x04USER\x10\x01\"\x8c\x01\n" +
+ "\x15PurchaseBillingMethod\x128\n" +
+ "\binterval\x18\x01 \x01(\x0e2\x1c.bytebase.v1.BillingIntervalR\binterval\x129\n" +
+ "\bdiscount\x18\x02 \x01(\v2\x1d.bytebase.v1.PurchaseDiscountR\bdiscount\"[\n" +
+ "\x10PurchaseDiscount\x12 \n" +
+ "\vdescription\x18\x01 \x01(\tR\vdescription\x12%\n" +
+ "\x0epromotion_code\x18\x02 \x01(\tR\rpromotionCode\"\x1a\n" +
+ "\x18ListPurchasePlansRequest\"L\n" +
+ "\x19ListPurchasePlansResponse\x12/\n" +
+ "\x05plans\x18\x01 \x03(\v2\x19.bytebase.v1.PurchasePlanR\x05plans\"\xc6\x02\n" +
"\fSubscription\x12.\n" +
"\x04plan\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeB\x03\xe0A\x03R\x04plan\x12\x19\n" +
"\x05seats\x18\x02 \x01(\x05B\x03\xe0A\x03R\x05seats\x12!\n" +
@@ -679,7 +1560,11 @@ const file_v1_subscription_service_proto_rawDesc = "" +
"\x04type\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeR\x04type\x124\n" +
"\x16maximum_instance_count\x18\x02 \x01(\x05R\x14maximumInstanceCount\x12,\n" +
"\x12maximum_seat_count\x18\x03 \x01(\x05R\x10maximumSeatCount\x124\n" +
- "\bfeatures\x18\x04 \x03(\x0e2\x18.bytebase.v1.PlanFeatureR\bfeatures*I\n" +
+ "\bfeatures\x18\x04 \x03(\x0e2\x18.bytebase.v1.PlanFeatureR\bfeatures*H\n" +
+ "\x0fBillingInterval\x12 \n" +
+ "\x1cBILLING_INTERVAL_UNSPECIFIED\x10\x00\x12\t\n" +
+ "\x05MONTH\x10\x01\x12\b\n" +
+ "\x04YEAR\x10\x02*I\n" +
"\bPlanType\x12\x19\n" +
"\x15PLAN_TYPE_UNSPECIFIED\x10\x00\x12\b\n" +
"\x04FREE\x10\x01\x12\b\n" +
@@ -759,10 +1644,15 @@ const file_v1_subscription_service_proto_rawDesc = "" +
"\x12FEATURE_CUSTOM_MSA\x10D\x12\x1d\n" +
"\x19FEATURE_COMMUNITY_SUPPORT\x10E\x12\x19\n" +
"\x15FEATURE_EMAIL_SUPPORT\x10F\x12&\n" +
- "\"FEATURE_DEDICATED_SUPPORT_WITH_SLA\x10G2\xa5\x02\n" +
+ "\"FEATURE_DEDICATED_SUPPORT_WITH_SLA\x10G2\xaf\b\n" +
"\x13SubscriptionService\x12r\n" +
"\x0fGetSubscription\x12#.bytebase.v1.GetSubscriptionRequest\x1a\x19.bytebase.v1.Subscription\"\x1f\xdaA\x00\x80\xea0\x01\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/subscription\x12\x99\x01\n" +
- "\x12UpdateSubscription\x12&.bytebase.v1.UpdateSubscriptionRequest\x1a\x19.bytebase.v1.Subscription\"@\xdaA\x05patch\x8a\xea0\x0fbb.settings.set\x90\xea0\x01\x82\xd3\xe4\x93\x02\x1b:\alicense2\x10/v1/subscriptionB\xae\x01\n" +
+ "\x12UpdateSubscription\x12&.bytebase.v1.UpdateSubscriptionRequest\x1a\x19.bytebase.v1.Subscription\"@\xdaA\x05patch\x8a\xea0\x0fbb.settings.set\x90\xea0\x01\x82\xd3\xe4\x93\x02\x1b:\alicense2\x10/v1/subscription\x12\x9d\x01\n" +
+ "\x0eCreatePurchase\x12\".bytebase.v1.CreatePurchaseRequest\x1a#.bytebase.v1.CreatePurchaseResponse\"B\x8a\xea0\x16bb.subscription.manage\x90\xea0\x01\x82\xd3\xe4\x93\x02\x1e:\x01*\"\x19/v1/subscription:purchase\x12\xa3\x01\n" +
+ "\x0eUpdatePurchase\x12\".bytebase.v1.UpdatePurchaseRequest\x1a#.bytebase.v1.UpdatePurchaseResponse\"H\x8a\xea0\x16bb.subscription.manage\x90\xea0\x01\x82\xd3\xe4\x93\x02$:\x01*\"\x1f/v1/subscription:updatePurchase\x12\xa3\x01\n" +
+ "\x0eCancelPurchase\x12\".bytebase.v1.CancelPurchaseRequest\x1a#.bytebase.v1.CancelPurchaseResponse\"H\x8a\xea0\x16bb.subscription.manage\x90\xea0\x01\x82\xd3\xe4\x93\x02$:\x01*\"\x1f/v1/subscription:cancelPurchase\x12\x92\x01\n" +
+ "\x0eGetPaymentInfo\x12\".bytebase.v1.GetPaymentInfoRequest\x1a\x18.bytebase.v1.PaymentInfo\"B\x8a\xea0\x16bb.subscription.manage\x90\xea0\x01\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v1/subscription/paymentInfo\x12\x86\x01\n" +
+ "\x11ListPurchasePlans\x12%.bytebase.v1.ListPurchasePlansRequest\x1a&.bytebase.v1.ListPurchasePlansResponse\"\"\x80\xea0\x01\x82\xd3\xe4\x93\x02\x18\x12\x16/v1/subscription/plansB\xae\x01\n" +
"\x0fcom.bytebase.v1B\x18SubscriptionServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"
var (
@@ -777,34 +1667,71 @@ func file_v1_subscription_service_proto_rawDescGZIP() []byte {
return file_v1_subscription_service_proto_rawDescData
}
-var file_v1_subscription_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
-var file_v1_subscription_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_v1_subscription_service_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
+var file_v1_subscription_service_proto_msgTypes = make([]protoimpl.MessageInfo, 19)
var file_v1_subscription_service_proto_goTypes = []any{
- (PlanType)(0), // 0: bytebase.v1.PlanType
- (PlanFeature)(0), // 1: bytebase.v1.PlanFeature
- (*GetSubscriptionRequest)(nil), // 2: bytebase.v1.GetSubscriptionRequest
- (*UpdateSubscriptionRequest)(nil), // 3: bytebase.v1.UpdateSubscriptionRequest
- (*Subscription)(nil), // 4: bytebase.v1.Subscription
- (*PlanConfig)(nil), // 5: bytebase.v1.PlanConfig
- (*PlanLimitConfig)(nil), // 6: bytebase.v1.PlanLimitConfig
- (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
+ (BillingInterval)(0), // 0: bytebase.v1.BillingInterval
+ (PlanType)(0), // 1: bytebase.v1.PlanType
+ (PlanFeature)(0), // 2: bytebase.v1.PlanFeature
+ (PurchasePlanAdditional_Type)(0), // 3: bytebase.v1.PurchasePlanAdditional.Type
+ (*GetSubscriptionRequest)(nil), // 4: bytebase.v1.GetSubscriptionRequest
+ (*UpdateSubscriptionRequest)(nil), // 5: bytebase.v1.UpdateSubscriptionRequest
+ (*CreatePurchaseRequest)(nil), // 6: bytebase.v1.CreatePurchaseRequest
+ (*CreatePurchaseResponse)(nil), // 7: bytebase.v1.CreatePurchaseResponse
+ (*UpdatePurchaseRequest)(nil), // 8: bytebase.v1.UpdatePurchaseRequest
+ (*UpdatePurchaseResponse)(nil), // 9: bytebase.v1.UpdatePurchaseResponse
+ (*CancelPurchaseRequest)(nil), // 10: bytebase.v1.CancelPurchaseRequest
+ (*CancelPurchaseResponse)(nil), // 11: bytebase.v1.CancelPurchaseResponse
+ (*GetPaymentInfoRequest)(nil), // 12: bytebase.v1.GetPaymentInfoRequest
+ (*PaymentInfo)(nil), // 13: bytebase.v1.PaymentInfo
+ (*PurchasePlan)(nil), // 14: bytebase.v1.PurchasePlan
+ (*PurchasePlanAdditional)(nil), // 15: bytebase.v1.PurchasePlanAdditional
+ (*PurchaseBillingMethod)(nil), // 16: bytebase.v1.PurchaseBillingMethod
+ (*PurchaseDiscount)(nil), // 17: bytebase.v1.PurchaseDiscount
+ (*ListPurchasePlansRequest)(nil), // 18: bytebase.v1.ListPurchasePlansRequest
+ (*ListPurchasePlansResponse)(nil), // 19: bytebase.v1.ListPurchasePlansResponse
+ (*Subscription)(nil), // 20: bytebase.v1.Subscription
+ (*PlanConfig)(nil), // 21: bytebase.v1.PlanConfig
+ (*PlanLimitConfig)(nil), // 22: bytebase.v1.PlanLimitConfig
+ (*timestamppb.Timestamp)(nil), // 23: google.protobuf.Timestamp
}
var file_v1_subscription_service_proto_depIdxs = []int32{
- 0, // 0: bytebase.v1.Subscription.plan:type_name -> bytebase.v1.PlanType
- 7, // 1: bytebase.v1.Subscription.expires_time:type_name -> google.protobuf.Timestamp
- 6, // 2: bytebase.v1.PlanConfig.plans:type_name -> bytebase.v1.PlanLimitConfig
- 1, // 3: bytebase.v1.PlanConfig.instance_features:type_name -> bytebase.v1.PlanFeature
- 0, // 4: bytebase.v1.PlanLimitConfig.type:type_name -> bytebase.v1.PlanType
- 1, // 5: bytebase.v1.PlanLimitConfig.features:type_name -> bytebase.v1.PlanFeature
- 2, // 6: bytebase.v1.SubscriptionService.GetSubscription:input_type -> bytebase.v1.GetSubscriptionRequest
- 3, // 7: bytebase.v1.SubscriptionService.UpdateSubscription:input_type -> bytebase.v1.UpdateSubscriptionRequest
- 4, // 8: bytebase.v1.SubscriptionService.GetSubscription:output_type -> bytebase.v1.Subscription
- 4, // 9: bytebase.v1.SubscriptionService.UpdateSubscription:output_type -> bytebase.v1.Subscription
- 8, // [8:10] is the sub-list for method output_type
- 6, // [6:8] is the sub-list for method input_type
- 6, // [6:6] is the sub-list for extension type_name
- 6, // [6:6] is the sub-list for extension extendee
- 0, // [0:6] is the sub-list for field type_name
+ 1, // 0: bytebase.v1.CreatePurchaseRequest.plan:type_name -> bytebase.v1.PlanType
+ 0, // 1: bytebase.v1.CreatePurchaseRequest.interval:type_name -> bytebase.v1.BillingInterval
+ 1, // 2: bytebase.v1.UpdatePurchaseRequest.plan:type_name -> bytebase.v1.PlanType
+ 0, // 3: bytebase.v1.UpdatePurchaseRequest.interval:type_name -> bytebase.v1.BillingInterval
+ 1, // 4: bytebase.v1.PurchasePlan.type:type_name -> bytebase.v1.PlanType
+ 15, // 5: bytebase.v1.PurchasePlan.additionals:type_name -> bytebase.v1.PurchasePlanAdditional
+ 16, // 6: bytebase.v1.PurchasePlan.billing_methods:type_name -> bytebase.v1.PurchaseBillingMethod
+ 3, // 7: bytebase.v1.PurchasePlanAdditional.type:type_name -> bytebase.v1.PurchasePlanAdditional.Type
+ 0, // 8: bytebase.v1.PurchaseBillingMethod.interval:type_name -> bytebase.v1.BillingInterval
+ 17, // 9: bytebase.v1.PurchaseBillingMethod.discount:type_name -> bytebase.v1.PurchaseDiscount
+ 14, // 10: bytebase.v1.ListPurchasePlansResponse.plans:type_name -> bytebase.v1.PurchasePlan
+ 1, // 11: bytebase.v1.Subscription.plan:type_name -> bytebase.v1.PlanType
+ 23, // 12: bytebase.v1.Subscription.expires_time:type_name -> google.protobuf.Timestamp
+ 22, // 13: bytebase.v1.PlanConfig.plans:type_name -> bytebase.v1.PlanLimitConfig
+ 2, // 14: bytebase.v1.PlanConfig.instance_features:type_name -> bytebase.v1.PlanFeature
+ 1, // 15: bytebase.v1.PlanLimitConfig.type:type_name -> bytebase.v1.PlanType
+ 2, // 16: bytebase.v1.PlanLimitConfig.features:type_name -> bytebase.v1.PlanFeature
+ 4, // 17: bytebase.v1.SubscriptionService.GetSubscription:input_type -> bytebase.v1.GetSubscriptionRequest
+ 5, // 18: bytebase.v1.SubscriptionService.UpdateSubscription:input_type -> bytebase.v1.UpdateSubscriptionRequest
+ 6, // 19: bytebase.v1.SubscriptionService.CreatePurchase:input_type -> bytebase.v1.CreatePurchaseRequest
+ 8, // 20: bytebase.v1.SubscriptionService.UpdatePurchase:input_type -> bytebase.v1.UpdatePurchaseRequest
+ 10, // 21: bytebase.v1.SubscriptionService.CancelPurchase:input_type -> bytebase.v1.CancelPurchaseRequest
+ 12, // 22: bytebase.v1.SubscriptionService.GetPaymentInfo:input_type -> bytebase.v1.GetPaymentInfoRequest
+ 18, // 23: bytebase.v1.SubscriptionService.ListPurchasePlans:input_type -> bytebase.v1.ListPurchasePlansRequest
+ 20, // 24: bytebase.v1.SubscriptionService.GetSubscription:output_type -> bytebase.v1.Subscription
+ 20, // 25: bytebase.v1.SubscriptionService.UpdateSubscription:output_type -> bytebase.v1.Subscription
+ 7, // 26: bytebase.v1.SubscriptionService.CreatePurchase:output_type -> bytebase.v1.CreatePurchaseResponse
+ 9, // 27: bytebase.v1.SubscriptionService.UpdatePurchase:output_type -> bytebase.v1.UpdatePurchaseResponse
+ 11, // 28: bytebase.v1.SubscriptionService.CancelPurchase:output_type -> bytebase.v1.CancelPurchaseResponse
+ 13, // 29: bytebase.v1.SubscriptionService.GetPaymentInfo:output_type -> bytebase.v1.PaymentInfo
+ 19, // 30: bytebase.v1.SubscriptionService.ListPurchasePlans:output_type -> bytebase.v1.ListPurchasePlansResponse
+ 24, // [24:31] is the sub-list for method output_type
+ 17, // [17:24] is the sub-list for method input_type
+ 17, // [17:17] is the sub-list for extension type_name
+ 17, // [17:17] is the sub-list for extension extendee
+ 0, // [0:17] is the sub-list for field type_name
}
func init() { file_v1_subscription_service_proto_init() }
@@ -818,8 +1745,8 @@ func file_v1_subscription_service_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_subscription_service_proto_rawDesc), len(file_v1_subscription_service_proto_rawDesc)),
- NumEnums: 2,
- NumMessages: 5,
+ NumEnums: 4,
+ NumMessages: 19,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/backend/generated-go/v1/subscription_service.pb.gw.go b/backend/generated-go/v1/subscription_service.pb.gw.go
index df89e5ed87..a4298f7509 100644
--- a/backend/generated-go/v1/subscription_service.pb.gw.go
+++ b/backend/generated-go/v1/subscription_service.pb.gw.go
@@ -97,6 +97,129 @@ func local_request_SubscriptionService_UpdateSubscription_0(ctx context.Context,
return msg, metadata, err
}
+func request_SubscriptionService_CreatePurchase_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq CreatePurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.CreatePurchase(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SubscriptionService_CreatePurchase_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq CreatePurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := server.CreatePurchase(ctx, &protoReq)
+ return msg, metadata, err
+}
+
+func request_SubscriptionService_UpdatePurchase_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq UpdatePurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.UpdatePurchase(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SubscriptionService_UpdatePurchase_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq UpdatePurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := server.UpdatePurchase(ctx, &protoReq)
+ return msg, metadata, err
+}
+
+func request_SubscriptionService_CancelPurchase_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq CancelPurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.CancelPurchase(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SubscriptionService_CancelPurchase_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq CancelPurchaseRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := server.CancelPurchase(ctx, &protoReq)
+ return msg, metadata, err
+}
+
+func request_SubscriptionService_GetPaymentInfo_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq GetPaymentInfoRequest
+ metadata runtime.ServerMetadata
+ )
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.GetPaymentInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SubscriptionService_GetPaymentInfo_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq GetPaymentInfoRequest
+ metadata runtime.ServerMetadata
+ )
+ msg, err := server.GetPaymentInfo(ctx, &protoReq)
+ return msg, metadata, err
+}
+
+func request_SubscriptionService_ListPurchasePlans_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq ListPurchasePlansRequest
+ metadata runtime.ServerMetadata
+ )
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.ListPurchasePlans(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_SubscriptionService_ListPurchasePlans_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq ListPurchasePlansRequest
+ metadata runtime.ServerMetadata
+ )
+ msg, err := server.ListPurchasePlans(ctx, &protoReq)
+ return msg, metadata, err
+}
+
// RegisterSubscriptionServiceHandlerServer registers the http handlers for service SubscriptionService to "mux".
// UnaryRPC :call SubscriptionServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -143,6 +266,106 @@ func RegisterSubscriptionServiceHandlerServer(ctx context.Context, mux *runtime.
}
forward_SubscriptionService_UpdateSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_CreatePurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/CreatePurchase", runtime.WithHTTPPathPattern("/v1/subscription:purchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_CreatePurchase_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_CreatePurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_UpdatePurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/UpdatePurchase", runtime.WithHTTPPathPattern("/v1/subscription:updatePurchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_UpdatePurchase_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_UpdatePurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_CancelPurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/CancelPurchase", runtime.WithHTTPPathPattern("/v1/subscription:cancelPurchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_CancelPurchase_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_CancelPurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodGet, pattern_SubscriptionService_GetPaymentInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/GetPaymentInfo", runtime.WithHTTPPathPattern("/v1/subscription/paymentInfo"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_GetPaymentInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_GetPaymentInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodGet, pattern_SubscriptionService_ListPurchasePlans_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/ListPurchasePlans", runtime.WithHTTPPathPattern("/v1/subscription/plans"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_ListPurchasePlans_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_ListPurchasePlans_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
@@ -217,15 +440,110 @@ func RegisterSubscriptionServiceHandlerClient(ctx context.Context, mux *runtime.
}
forward_SubscriptionService_UpdateSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_CreatePurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/CreatePurchase", runtime.WithHTTPPathPattern("/v1/subscription:purchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_CreatePurchase_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_CreatePurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_UpdatePurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/UpdatePurchase", runtime.WithHTTPPathPattern("/v1/subscription:updatePurchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_UpdatePurchase_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_UpdatePurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_SubscriptionService_CancelPurchase_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/CancelPurchase", runtime.WithHTTPPathPattern("/v1/subscription:cancelPurchase"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_CancelPurchase_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_CancelPurchase_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodGet, pattern_SubscriptionService_GetPaymentInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/GetPaymentInfo", runtime.WithHTTPPathPattern("/v1/subscription/paymentInfo"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_GetPaymentInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_GetPaymentInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodGet, pattern_SubscriptionService_ListPurchasePlans_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/ListPurchasePlans", runtime.WithHTTPPathPattern("/v1/subscription/plans"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_ListPurchasePlans_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_SubscriptionService_ListPurchasePlans_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
var (
pattern_SubscriptionService_GetSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
pattern_SubscriptionService_UpdateSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
+ pattern_SubscriptionService_CreatePurchase_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, "purchase"))
+ pattern_SubscriptionService_UpdatePurchase_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, "updatePurchase"))
+ pattern_SubscriptionService_CancelPurchase_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, "cancelPurchase"))
+ pattern_SubscriptionService_GetPaymentInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "subscription", "paymentInfo"}, ""))
+ pattern_SubscriptionService_ListPurchasePlans_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "subscription", "plans"}, ""))
)
var (
forward_SubscriptionService_GetSubscription_0 = runtime.ForwardResponseMessage
forward_SubscriptionService_UpdateSubscription_0 = runtime.ForwardResponseMessage
+ forward_SubscriptionService_CreatePurchase_0 = runtime.ForwardResponseMessage
+ forward_SubscriptionService_UpdatePurchase_0 = runtime.ForwardResponseMessage
+ forward_SubscriptionService_CancelPurchase_0 = runtime.ForwardResponseMessage
+ forward_SubscriptionService_GetPaymentInfo_0 = runtime.ForwardResponseMessage
+ forward_SubscriptionService_ListPurchasePlans_0 = runtime.ForwardResponseMessage
)
diff --git a/backend/generated-go/v1/subscription_service_equal.pb.go b/backend/generated-go/v1/subscription_service_equal.pb.go
index 9c7c33488e..f4ff1b073d 100644
--- a/backend/generated-go/v1/subscription_service_equal.pb.go
+++ b/backend/generated-go/v1/subscription_service_equal.pb.go
@@ -29,6 +29,245 @@ func (x *UpdateSubscriptionRequest) Equal(y *UpdateSubscriptionRequest) bool {
return true
}
+func (x *CreatePurchaseRequest) Equal(y *CreatePurchaseRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Plan != y.Plan {
+ return false
+ }
+ if x.Interval != y.Interval {
+ return false
+ }
+ if x.Seats != y.Seats {
+ return false
+ }
+ return true
+}
+
+func (x *CreatePurchaseResponse) Equal(y *CreatePurchaseResponse) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.PaymentUrl != y.PaymentUrl {
+ return false
+ }
+ return true
+}
+
+func (x *UpdatePurchaseRequest) Equal(y *UpdatePurchaseRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Plan != y.Plan {
+ return false
+ }
+ if x.Interval != y.Interval {
+ return false
+ }
+ if x.Seats != y.Seats {
+ return false
+ }
+ if x.Etag != y.Etag {
+ return false
+ }
+ return true
+}
+
+func (x *UpdatePurchaseResponse) Equal(y *UpdatePurchaseResponse) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.PaymentUrl != y.PaymentUrl {
+ return false
+ }
+ return true
+}
+
+func (x *CancelPurchaseRequest) Equal(y *CancelPurchaseRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ return true
+}
+
+func (x *CancelPurchaseResponse) Equal(y *CancelPurchaseResponse) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ return true
+}
+
+func (x *GetPaymentInfoRequest) Equal(y *GetPaymentInfoRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ return true
+}
+
+func (x *PaymentInfo) Equal(y *PaymentInfo) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.TotalPrice != y.TotalPrice {
+ return false
+ }
+ if x.Currency != y.Currency {
+ return false
+ }
+ if x.PeriodStart != y.PeriodStart {
+ return false
+ }
+ if x.PeriodEnd != y.PeriodEnd {
+ return false
+ }
+ if x.InvoiceUrl != y.InvoiceUrl {
+ return false
+ }
+ return true
+}
+
+func (x *PurchasePlan) Equal(y *PurchasePlan) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Type != y.Type {
+ return false
+ }
+ if x.SelfServicePurchase != y.SelfServicePurchase {
+ return false
+ }
+ if len(x.Additionals) != len(y.Additionals) {
+ return false
+ }
+ for i := 0; i < len(x.Additionals); i++ {
+ if !x.Additionals[i].Equal(y.Additionals[i]) {
+ return false
+ }
+ }
+ if len(x.BillingMethods) != len(y.BillingMethods) {
+ return false
+ }
+ for i := 0; i < len(x.BillingMethods); i++ {
+ if !x.BillingMethods[i].Equal(y.BillingMethods[i]) {
+ return false
+ }
+ }
+ return true
+}
+
+func (x *PurchasePlanAdditional) Equal(y *PurchasePlanAdditional) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Type != y.Type {
+ return false
+ }
+ if x.UnitPrice != y.UnitPrice {
+ return false
+ }
+ if x.FreeCount != y.FreeCount {
+ return false
+ }
+ if x.MinimumCount != y.MinimumCount {
+ return false
+ }
+ if x.MaximumCount != y.MaximumCount {
+ return false
+ }
+ return true
+}
+
+func (x *PurchaseBillingMethod) Equal(y *PurchaseBillingMethod) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Interval != y.Interval {
+ return false
+ }
+ if !x.Discount.Equal(y.Discount) {
+ return false
+ }
+ return true
+}
+
+func (x *PurchaseDiscount) Equal(y *PurchaseDiscount) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Description != y.Description {
+ return false
+ }
+ if x.PromotionCode != y.PromotionCode {
+ return false
+ }
+ return true
+}
+
+func (x *ListPurchasePlansRequest) Equal(y *ListPurchasePlansRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ return true
+}
+
+func (x *ListPurchasePlansResponse) Equal(y *ListPurchasePlansResponse) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if len(x.Plans) != len(y.Plans) {
+ return false
+ }
+ for i := 0; i < len(x.Plans); i++ {
+ if !x.Plans[i].Equal(y.Plans[i]) {
+ return false
+ }
+ }
+ return true
+}
+
func (x *Subscription) Equal(y *Subscription) bool {
if x == y {
return true
diff --git a/backend/generated-go/v1/subscription_service_grpc.pb.go b/backend/generated-go/v1/subscription_service_grpc.pb.go
index 6375c57fd0..aaf65473c5 100644
--- a/backend/generated-go/v1/subscription_service_grpc.pb.go
+++ b/backend/generated-go/v1/subscription_service_grpc.pb.go
@@ -21,6 +21,11 @@ const _ = grpc.SupportPackageIsVersion9
const (
SubscriptionService_GetSubscription_FullMethodName = "/bytebase.v1.SubscriptionService/GetSubscription"
SubscriptionService_UpdateSubscription_FullMethodName = "/bytebase.v1.SubscriptionService/UpdateSubscription"
+ SubscriptionService_CreatePurchase_FullMethodName = "/bytebase.v1.SubscriptionService/CreatePurchase"
+ SubscriptionService_UpdatePurchase_FullMethodName = "/bytebase.v1.SubscriptionService/UpdatePurchase"
+ SubscriptionService_CancelPurchase_FullMethodName = "/bytebase.v1.SubscriptionService/CancelPurchase"
+ SubscriptionService_GetPaymentInfo_FullMethodName = "/bytebase.v1.SubscriptionService/GetPaymentInfo"
+ SubscriptionService_ListPurchasePlans_FullMethodName = "/bytebase.v1.SubscriptionService/ListPurchasePlans"
)
// SubscriptionServiceClient is the client API for SubscriptionService service.
@@ -34,9 +39,21 @@ type SubscriptionServiceClient interface {
// If there is expired license, we will return a free plan subscription with the expiration time of the expired license.
// Permissions required: None
GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
- // Updates the enterprise license subscription.
+ // Updates the enterprise license subscription (self-hosted only).
// Permissions required: bb.settings.set
UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
+ // CreatePurchase creates a new subscription purchase (SaaS only).
+ // Returns a Stripe Checkout URL for the user to complete payment.
+ CreatePurchase(ctx context.Context, in *CreatePurchaseRequest, opts ...grpc.CallOption) (*CreatePurchaseResponse, error)
+ // UpdatePurchase updates an existing subscription (SaaS only).
+ // May return a Stripe Checkout URL if payment method change is needed.
+ UpdatePurchase(ctx context.Context, in *UpdatePurchaseRequest, opts ...grpc.CallOption) (*UpdatePurchaseResponse, error)
+ // CancelPurchase cancels an active subscription (SaaS only).
+ CancelPurchase(ctx context.Context, in *CancelPurchaseRequest, opts ...grpc.CallOption) (*CancelPurchaseResponse, error)
+ // GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ GetPaymentInfo(ctx context.Context, in *GetPaymentInfoRequest, opts ...grpc.CallOption) (*PaymentInfo, error)
+ // ListPurchasePlans returns available plans for self-service purchase.
+ ListPurchasePlans(ctx context.Context, in *ListPurchasePlansRequest, opts ...grpc.CallOption) (*ListPurchasePlansResponse, error)
}
type subscriptionServiceClient struct {
@@ -67,6 +84,56 @@ func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, in *
return out, nil
}
+func (c *subscriptionServiceClient) CreatePurchase(ctx context.Context, in *CreatePurchaseRequest, opts ...grpc.CallOption) (*CreatePurchaseResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(CreatePurchaseResponse)
+ err := c.cc.Invoke(ctx, SubscriptionService_CreatePurchase_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) UpdatePurchase(ctx context.Context, in *UpdatePurchaseRequest, opts ...grpc.CallOption) (*UpdatePurchaseResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(UpdatePurchaseResponse)
+ err := c.cc.Invoke(ctx, SubscriptionService_UpdatePurchase_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) CancelPurchase(ctx context.Context, in *CancelPurchaseRequest, opts ...grpc.CallOption) (*CancelPurchaseResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(CancelPurchaseResponse)
+ err := c.cc.Invoke(ctx, SubscriptionService_CancelPurchase_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) GetPaymentInfo(ctx context.Context, in *GetPaymentInfoRequest, opts ...grpc.CallOption) (*PaymentInfo, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(PaymentInfo)
+ err := c.cc.Invoke(ctx, SubscriptionService_GetPaymentInfo_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) ListPurchasePlans(ctx context.Context, in *ListPurchasePlansRequest, opts ...grpc.CallOption) (*ListPurchasePlansResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(ListPurchasePlansResponse)
+ err := c.cc.Invoke(ctx, SubscriptionService_ListPurchasePlans_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// SubscriptionServiceServer is the server API for SubscriptionService service.
// All implementations must embed UnimplementedSubscriptionServiceServer
// for forward compatibility.
@@ -78,9 +145,21 @@ type SubscriptionServiceServer interface {
// If there is expired license, we will return a free plan subscription with the expiration time of the expired license.
// Permissions required: None
GetSubscription(context.Context, *GetSubscriptionRequest) (*Subscription, error)
- // Updates the enterprise license subscription.
+ // Updates the enterprise license subscription (self-hosted only).
// Permissions required: bb.settings.set
UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error)
+ // CreatePurchase creates a new subscription purchase (SaaS only).
+ // Returns a Stripe Checkout URL for the user to complete payment.
+ CreatePurchase(context.Context, *CreatePurchaseRequest) (*CreatePurchaseResponse, error)
+ // UpdatePurchase updates an existing subscription (SaaS only).
+ // May return a Stripe Checkout URL if payment method change is needed.
+ UpdatePurchase(context.Context, *UpdatePurchaseRequest) (*UpdatePurchaseResponse, error)
+ // CancelPurchase cancels an active subscription (SaaS only).
+ CancelPurchase(context.Context, *CancelPurchaseRequest) (*CancelPurchaseResponse, error)
+ // GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ GetPaymentInfo(context.Context, *GetPaymentInfoRequest) (*PaymentInfo, error)
+ // ListPurchasePlans returns available plans for self-service purchase.
+ ListPurchasePlans(context.Context, *ListPurchasePlansRequest) (*ListPurchasePlansResponse, error)
mustEmbedUnimplementedSubscriptionServiceServer()
}
@@ -97,6 +176,21 @@ func (UnimplementedSubscriptionServiceServer) GetSubscription(context.Context, *
func (UnimplementedSubscriptionServiceServer) UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateSubscription not implemented")
}
+func (UnimplementedSubscriptionServiceServer) CreatePurchase(context.Context, *CreatePurchaseRequest) (*CreatePurchaseResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method CreatePurchase not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) UpdatePurchase(context.Context, *UpdatePurchaseRequest) (*UpdatePurchaseResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method UpdatePurchase not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) CancelPurchase(context.Context, *CancelPurchaseRequest) (*CancelPurchaseResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method CancelPurchase not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) GetPaymentInfo(context.Context, *GetPaymentInfoRequest) (*PaymentInfo, error) {
+ return nil, status.Error(codes.Unimplemented, "method GetPaymentInfo not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) ListPurchasePlans(context.Context, *ListPurchasePlansRequest) (*ListPurchasePlansResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method ListPurchasePlans not implemented")
+}
func (UnimplementedSubscriptionServiceServer) mustEmbedUnimplementedSubscriptionServiceServer() {}
func (UnimplementedSubscriptionServiceServer) testEmbeddedByValue() {}
@@ -154,6 +248,96 @@ func _SubscriptionService_UpdateSubscription_Handler(srv interface{}, ctx contex
return interceptor(ctx, in, info, handler)
}
+func _SubscriptionService_CreatePurchase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(CreatePurchaseRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).CreatePurchase(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_CreatePurchase_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).CreatePurchase(ctx, req.(*CreatePurchaseRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_UpdatePurchase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UpdatePurchaseRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).UpdatePurchase(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_UpdatePurchase_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).UpdatePurchase(ctx, req.(*UpdatePurchaseRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_CancelPurchase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(CancelPurchaseRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).CancelPurchase(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_CancelPurchase_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).CancelPurchase(ctx, req.(*CancelPurchaseRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_GetPaymentInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetPaymentInfoRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).GetPaymentInfo(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_GetPaymentInfo_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).GetPaymentInfo(ctx, req.(*GetPaymentInfoRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_ListPurchasePlans_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ListPurchasePlansRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).ListPurchasePlans(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_ListPurchasePlans_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).ListPurchasePlans(ctx, req.(*ListPurchasePlansRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// SubscriptionService_ServiceDesc is the grpc.ServiceDesc for SubscriptionService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -169,6 +353,26 @@ var SubscriptionService_ServiceDesc = grpc.ServiceDesc{
MethodName: "UpdateSubscription",
Handler: _SubscriptionService_UpdateSubscription_Handler,
},
+ {
+ MethodName: "CreatePurchase",
+ Handler: _SubscriptionService_CreatePurchase_Handler,
+ },
+ {
+ MethodName: "UpdatePurchase",
+ Handler: _SubscriptionService_UpdatePurchase_Handler,
+ },
+ {
+ MethodName: "CancelPurchase",
+ Handler: _SubscriptionService_CancelPurchase_Handler,
+ },
+ {
+ MethodName: "GetPaymentInfo",
+ Handler: _SubscriptionService_GetPaymentInfo_Handler,
+ },
+ {
+ MethodName: "ListPurchasePlans",
+ Handler: _SubscriptionService_ListPurchasePlans_Handler,
+ },
},
Streams: []grpc.StreamDesc{},
Metadata: "v1/subscription_service.proto",
diff --git a/backend/generated-go/v1/v1connect/subscription_service.connect.go b/backend/generated-go/v1/v1connect/subscription_service.connect.go
index 43d9463bbd..e794771b7d 100644
--- a/backend/generated-go/v1/v1connect/subscription_service.connect.go
+++ b/backend/generated-go/v1/v1connect/subscription_service.connect.go
@@ -39,6 +39,21 @@ const (
// SubscriptionServiceUpdateSubscriptionProcedure is the fully-qualified name of the
// SubscriptionService's UpdateSubscription RPC.
SubscriptionServiceUpdateSubscriptionProcedure = "/bytebase.v1.SubscriptionService/UpdateSubscription"
+ // SubscriptionServiceCreatePurchaseProcedure is the fully-qualified name of the
+ // SubscriptionService's CreatePurchase RPC.
+ SubscriptionServiceCreatePurchaseProcedure = "/bytebase.v1.SubscriptionService/CreatePurchase"
+ // SubscriptionServiceUpdatePurchaseProcedure is the fully-qualified name of the
+ // SubscriptionService's UpdatePurchase RPC.
+ SubscriptionServiceUpdatePurchaseProcedure = "/bytebase.v1.SubscriptionService/UpdatePurchase"
+ // SubscriptionServiceCancelPurchaseProcedure is the fully-qualified name of the
+ // SubscriptionService's CancelPurchase RPC.
+ SubscriptionServiceCancelPurchaseProcedure = "/bytebase.v1.SubscriptionService/CancelPurchase"
+ // SubscriptionServiceGetPaymentInfoProcedure is the fully-qualified name of the
+ // SubscriptionService's GetPaymentInfo RPC.
+ SubscriptionServiceGetPaymentInfoProcedure = "/bytebase.v1.SubscriptionService/GetPaymentInfo"
+ // SubscriptionServiceListPurchasePlansProcedure is the fully-qualified name of the
+ // SubscriptionService's ListPurchasePlans RPC.
+ SubscriptionServiceListPurchasePlansProcedure = "/bytebase.v1.SubscriptionService/ListPurchasePlans"
)
// SubscriptionServiceClient is a client for the bytebase.v1.SubscriptionService service.
@@ -48,9 +63,21 @@ type SubscriptionServiceClient interface {
// If there is expired license, we will return a free plan subscription with the expiration time of the expired license.
// Permissions required: None
GetSubscription(context.Context, *connect.Request[v1.GetSubscriptionRequest]) (*connect.Response[v1.Subscription], error)
- // Updates the enterprise license subscription.
+ // Updates the enterprise license subscription (self-hosted only).
// Permissions required: bb.settings.set
UpdateSubscription(context.Context, *connect.Request[v1.UpdateSubscriptionRequest]) (*connect.Response[v1.Subscription], error)
+ // CreatePurchase creates a new subscription purchase (SaaS only).
+ // Returns a Stripe Checkout URL for the user to complete payment.
+ CreatePurchase(context.Context, *connect.Request[v1.CreatePurchaseRequest]) (*connect.Response[v1.CreatePurchaseResponse], error)
+ // UpdatePurchase updates an existing subscription (SaaS only).
+ // May return a Stripe Checkout URL if payment method change is needed.
+ UpdatePurchase(context.Context, *connect.Request[v1.UpdatePurchaseRequest]) (*connect.Response[v1.UpdatePurchaseResponse], error)
+ // CancelPurchase cancels an active subscription (SaaS only).
+ CancelPurchase(context.Context, *connect.Request[v1.CancelPurchaseRequest]) (*connect.Response[v1.CancelPurchaseResponse], error)
+ // GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ GetPaymentInfo(context.Context, *connect.Request[v1.GetPaymentInfoRequest]) (*connect.Response[v1.PaymentInfo], error)
+ // ListPurchasePlans returns available plans for self-service purchase.
+ ListPurchasePlans(context.Context, *connect.Request[v1.ListPurchasePlansRequest]) (*connect.Response[v1.ListPurchasePlansResponse], error)
}
// NewSubscriptionServiceClient constructs a client for the bytebase.v1.SubscriptionService service.
@@ -76,6 +103,36 @@ func NewSubscriptionServiceClient(httpClient connect.HTTPClient, baseURL string,
connect.WithSchema(subscriptionServiceMethods.ByName("UpdateSubscription")),
connect.WithClientOptions(opts...),
),
+ createPurchase: connect.NewClient[v1.CreatePurchaseRequest, v1.CreatePurchaseResponse](
+ httpClient,
+ baseURL+SubscriptionServiceCreatePurchaseProcedure,
+ connect.WithSchema(subscriptionServiceMethods.ByName("CreatePurchase")),
+ connect.WithClientOptions(opts...),
+ ),
+ updatePurchase: connect.NewClient[v1.UpdatePurchaseRequest, v1.UpdatePurchaseResponse](
+ httpClient,
+ baseURL+SubscriptionServiceUpdatePurchaseProcedure,
+ connect.WithSchema(subscriptionServiceMethods.ByName("UpdatePurchase")),
+ connect.WithClientOptions(opts...),
+ ),
+ cancelPurchase: connect.NewClient[v1.CancelPurchaseRequest, v1.CancelPurchaseResponse](
+ httpClient,
+ baseURL+SubscriptionServiceCancelPurchaseProcedure,
+ connect.WithSchema(subscriptionServiceMethods.ByName("CancelPurchase")),
+ connect.WithClientOptions(opts...),
+ ),
+ getPaymentInfo: connect.NewClient[v1.GetPaymentInfoRequest, v1.PaymentInfo](
+ httpClient,
+ baseURL+SubscriptionServiceGetPaymentInfoProcedure,
+ connect.WithSchema(subscriptionServiceMethods.ByName("GetPaymentInfo")),
+ connect.WithClientOptions(opts...),
+ ),
+ listPurchasePlans: connect.NewClient[v1.ListPurchasePlansRequest, v1.ListPurchasePlansResponse](
+ httpClient,
+ baseURL+SubscriptionServiceListPurchasePlansProcedure,
+ connect.WithSchema(subscriptionServiceMethods.ByName("ListPurchasePlans")),
+ connect.WithClientOptions(opts...),
+ ),
}
}
@@ -83,6 +140,11 @@ func NewSubscriptionServiceClient(httpClient connect.HTTPClient, baseURL string,
type subscriptionServiceClient struct {
getSubscription *connect.Client[v1.GetSubscriptionRequest, v1.Subscription]
updateSubscription *connect.Client[v1.UpdateSubscriptionRequest, v1.Subscription]
+ createPurchase *connect.Client[v1.CreatePurchaseRequest, v1.CreatePurchaseResponse]
+ updatePurchase *connect.Client[v1.UpdatePurchaseRequest, v1.UpdatePurchaseResponse]
+ cancelPurchase *connect.Client[v1.CancelPurchaseRequest, v1.CancelPurchaseResponse]
+ getPaymentInfo *connect.Client[v1.GetPaymentInfoRequest, v1.PaymentInfo]
+ listPurchasePlans *connect.Client[v1.ListPurchasePlansRequest, v1.ListPurchasePlansResponse]
}
// GetSubscription calls bytebase.v1.SubscriptionService.GetSubscription.
@@ -95,6 +157,31 @@ func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, req
return c.updateSubscription.CallUnary(ctx, req)
}
+// CreatePurchase calls bytebase.v1.SubscriptionService.CreatePurchase.
+func (c *subscriptionServiceClient) CreatePurchase(ctx context.Context, req *connect.Request[v1.CreatePurchaseRequest]) (*connect.Response[v1.CreatePurchaseResponse], error) {
+ return c.createPurchase.CallUnary(ctx, req)
+}
+
+// UpdatePurchase calls bytebase.v1.SubscriptionService.UpdatePurchase.
+func (c *subscriptionServiceClient) UpdatePurchase(ctx context.Context, req *connect.Request[v1.UpdatePurchaseRequest]) (*connect.Response[v1.UpdatePurchaseResponse], error) {
+ return c.updatePurchase.CallUnary(ctx, req)
+}
+
+// CancelPurchase calls bytebase.v1.SubscriptionService.CancelPurchase.
+func (c *subscriptionServiceClient) CancelPurchase(ctx context.Context, req *connect.Request[v1.CancelPurchaseRequest]) (*connect.Response[v1.CancelPurchaseResponse], error) {
+ return c.cancelPurchase.CallUnary(ctx, req)
+}
+
+// GetPaymentInfo calls bytebase.v1.SubscriptionService.GetPaymentInfo.
+func (c *subscriptionServiceClient) GetPaymentInfo(ctx context.Context, req *connect.Request[v1.GetPaymentInfoRequest]) (*connect.Response[v1.PaymentInfo], error) {
+ return c.getPaymentInfo.CallUnary(ctx, req)
+}
+
+// ListPurchasePlans calls bytebase.v1.SubscriptionService.ListPurchasePlans.
+func (c *subscriptionServiceClient) ListPurchasePlans(ctx context.Context, req *connect.Request[v1.ListPurchasePlansRequest]) (*connect.Response[v1.ListPurchasePlansResponse], error) {
+ return c.listPurchasePlans.CallUnary(ctx, req)
+}
+
// SubscriptionServiceHandler is an implementation of the bytebase.v1.SubscriptionService service.
type SubscriptionServiceHandler interface {
// GetSubscription returns the current subscription.
@@ -102,9 +189,21 @@ type SubscriptionServiceHandler interface {
// If there is expired license, we will return a free plan subscription with the expiration time of the expired license.
// Permissions required: None
GetSubscription(context.Context, *connect.Request[v1.GetSubscriptionRequest]) (*connect.Response[v1.Subscription], error)
- // Updates the enterprise license subscription.
+ // Updates the enterprise license subscription (self-hosted only).
// Permissions required: bb.settings.set
UpdateSubscription(context.Context, *connect.Request[v1.UpdateSubscriptionRequest]) (*connect.Response[v1.Subscription], error)
+ // CreatePurchase creates a new subscription purchase (SaaS only).
+ // Returns a Stripe Checkout URL for the user to complete payment.
+ CreatePurchase(context.Context, *connect.Request[v1.CreatePurchaseRequest]) (*connect.Response[v1.CreatePurchaseResponse], error)
+ // UpdatePurchase updates an existing subscription (SaaS only).
+ // May return a Stripe Checkout URL if payment method change is needed.
+ UpdatePurchase(context.Context, *connect.Request[v1.UpdatePurchaseRequest]) (*connect.Response[v1.UpdatePurchaseResponse], error)
+ // CancelPurchase cancels an active subscription (SaaS only).
+ CancelPurchase(context.Context, *connect.Request[v1.CancelPurchaseRequest]) (*connect.Response[v1.CancelPurchaseResponse], error)
+ // GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ GetPaymentInfo(context.Context, *connect.Request[v1.GetPaymentInfoRequest]) (*connect.Response[v1.PaymentInfo], error)
+ // ListPurchasePlans returns available plans for self-service purchase.
+ ListPurchasePlans(context.Context, *connect.Request[v1.ListPurchasePlansRequest]) (*connect.Response[v1.ListPurchasePlansResponse], error)
}
// NewSubscriptionServiceHandler builds an HTTP handler from the service implementation. It returns
@@ -126,12 +225,52 @@ func NewSubscriptionServiceHandler(svc SubscriptionServiceHandler, opts ...conne
connect.WithSchema(subscriptionServiceMethods.ByName("UpdateSubscription")),
connect.WithHandlerOptions(opts...),
)
+ subscriptionServiceCreatePurchaseHandler := connect.NewUnaryHandler(
+ SubscriptionServiceCreatePurchaseProcedure,
+ svc.CreatePurchase,
+ connect.WithSchema(subscriptionServiceMethods.ByName("CreatePurchase")),
+ connect.WithHandlerOptions(opts...),
+ )
+ subscriptionServiceUpdatePurchaseHandler := connect.NewUnaryHandler(
+ SubscriptionServiceUpdatePurchaseProcedure,
+ svc.UpdatePurchase,
+ connect.WithSchema(subscriptionServiceMethods.ByName("UpdatePurchase")),
+ connect.WithHandlerOptions(opts...),
+ )
+ subscriptionServiceCancelPurchaseHandler := connect.NewUnaryHandler(
+ SubscriptionServiceCancelPurchaseProcedure,
+ svc.CancelPurchase,
+ connect.WithSchema(subscriptionServiceMethods.ByName("CancelPurchase")),
+ connect.WithHandlerOptions(opts...),
+ )
+ subscriptionServiceGetPaymentInfoHandler := connect.NewUnaryHandler(
+ SubscriptionServiceGetPaymentInfoProcedure,
+ svc.GetPaymentInfo,
+ connect.WithSchema(subscriptionServiceMethods.ByName("GetPaymentInfo")),
+ connect.WithHandlerOptions(opts...),
+ )
+ subscriptionServiceListPurchasePlansHandler := connect.NewUnaryHandler(
+ SubscriptionServiceListPurchasePlansProcedure,
+ svc.ListPurchasePlans,
+ connect.WithSchema(subscriptionServiceMethods.ByName("ListPurchasePlans")),
+ connect.WithHandlerOptions(opts...),
+ )
return "/bytebase.v1.SubscriptionService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case SubscriptionServiceGetSubscriptionProcedure:
subscriptionServiceGetSubscriptionHandler.ServeHTTP(w, r)
case SubscriptionServiceUpdateSubscriptionProcedure:
subscriptionServiceUpdateSubscriptionHandler.ServeHTTP(w, r)
+ case SubscriptionServiceCreatePurchaseProcedure:
+ subscriptionServiceCreatePurchaseHandler.ServeHTTP(w, r)
+ case SubscriptionServiceUpdatePurchaseProcedure:
+ subscriptionServiceUpdatePurchaseHandler.ServeHTTP(w, r)
+ case SubscriptionServiceCancelPurchaseProcedure:
+ subscriptionServiceCancelPurchaseHandler.ServeHTTP(w, r)
+ case SubscriptionServiceGetPaymentInfoProcedure:
+ subscriptionServiceGetPaymentInfoHandler.ServeHTTP(w, r)
+ case SubscriptionServiceListPurchasePlansProcedure:
+ subscriptionServiceListPurchasePlansHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
@@ -148,3 +287,23 @@ func (UnimplementedSubscriptionServiceHandler) GetSubscription(context.Context,
func (UnimplementedSubscriptionServiceHandler) UpdateSubscription(context.Context, *connect.Request[v1.UpdateSubscriptionRequest]) (*connect.Response[v1.Subscription], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.UpdateSubscription is not implemented"))
}
+
+func (UnimplementedSubscriptionServiceHandler) CreatePurchase(context.Context, *connect.Request[v1.CreatePurchaseRequest]) (*connect.Response[v1.CreatePurchaseResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.CreatePurchase is not implemented"))
+}
+
+func (UnimplementedSubscriptionServiceHandler) UpdatePurchase(context.Context, *connect.Request[v1.UpdatePurchaseRequest]) (*connect.Response[v1.UpdatePurchaseResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.UpdatePurchase is not implemented"))
+}
+
+func (UnimplementedSubscriptionServiceHandler) CancelPurchase(context.Context, *connect.Request[v1.CancelPurchaseRequest]) (*connect.Response[v1.CancelPurchaseResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.CancelPurchase is not implemented"))
+}
+
+func (UnimplementedSubscriptionServiceHandler) GetPaymentInfo(context.Context, *connect.Request[v1.GetPaymentInfoRequest]) (*connect.Response[v1.PaymentInfo], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.GetPaymentInfo is not implemented"))
+}
+
+func (UnimplementedSubscriptionServiceHandler) ListPurchasePlans(context.Context, *connect.Request[v1.ListPurchasePlansRequest]) (*connect.Response[v1.ListPurchasePlansResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.SubscriptionService.ListPurchasePlans is not implemented"))
+}
diff --git a/backend/server/echo_routes.go b/backend/server/echo_routes.go
index fb9acc57d6..a6cb67a0e0 100644
--- a/backend/server/echo_routes.go
+++ b/backend/server/echo_routes.go
@@ -17,9 +17,11 @@ import (
"github.com/bytebase/bytebase/backend/api/lsp"
"github.com/bytebase/bytebase/backend/api/mcp"
"github.com/bytebase/bytebase/backend/api/oauth2"
+ stripeapi "github.com/bytebase/bytebase/backend/api/stripe"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
+ stripeplugin "github.com/bytebase/bytebase/backend/plugin/stripe"
)
func configureEchoRouters(
@@ -28,6 +30,7 @@ func configureEchoRouters(
directorySyncServer *directorysync.Service,
oauth2Service *oauth2.Service,
mcpServer *mcp.Server,
+ stripeWebhookHandler *stripeapi.WebhookHandler,
profile *config.Profile,
) {
e.Use(recoverMiddleware)
@@ -80,6 +83,13 @@ func configureEchoRouters(
scimGroup := hookGroup.Group(scimAPIPrefix)
directorySyncServer.RegisterDirectorySyncRoutes(scimGroup)
+ // Stripe (SaaS only).
+ if profile.SaaS && profile.StripeAPIKey != "" {
+ stripeplugin.Init(profile.StripeAPIKey)
+ stripeGroup := hookGroup.Group("/stripe")
+ stripeWebhookHandler.RegisterRoutes(stripeGroup)
+ }
+
// OAuth2 server.
oauth2Service.RegisterRoutes(e)
diff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.go
index 70a19b81e4..416f110318 100644
--- a/backend/server/grpc_routes.go
+++ b/backend/server/grpc_routes.go
@@ -112,7 +112,7 @@ func configureGrpcRouters(
settingService := apiv1.NewSettingService(stores, profile, licenseService, iamManager)
sheetService := apiv1.NewSheetService(stores)
sqlService := apiv1.NewSQLService(stores, schemaSyncer, dbFactory, licenseService, iamManager)
- subscriptionService := apiv1.NewSubscriptionService(profile, licenseService)
+ subscriptionService := apiv1.NewSubscriptionService(profile, stores, licenseService)
userService := apiv1.NewUserService(stores, licenseService, profile, iamManager)
serviceAccountService := apiv1.NewServiceAccountService(stores, profile, iamManager)
workloadIdentityService := apiv1.NewWorkloadIdentityService(stores, profile, iamManager)
diff --git a/backend/server/server.go b/backend/server/server.go
index 02a0f1368b..0024c908dd 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -20,6 +20,7 @@ import (
"github.com/bytebase/bytebase/backend/api/lsp"
"github.com/bytebase/bytebase/backend/api/mcp"
"github.com/bytebase/bytebase/backend/api/oauth2"
+ stripeapi "github.com/bytebase/bytebase/backend/api/stripe"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/bus"
@@ -246,10 +247,12 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
return nil, errors.Wrapf(err, "failed to create MCP server")
}
+ stripeWebhookHandler := stripeapi.NewWebhookHandler(s.store, s.licenseService, profile.StripeWebhookSecret)
+
if err := configureGrpcRouters(ctx, s.echoServer, s.store, sheetManager, s.dbFactory, s.licenseService, s.profile, s.bus, s.schemaSyncer, s.webhookManager, s.iamManager, secret, s.sampleInstanceManager); err != nil {
return nil, errors.Wrapf(err, "failed to configure gRPC routers")
}
- configureEchoRouters(s.echoServer, s.lspServer, directorySyncServer, oauth2Service, mcpServer, profile)
+ configureEchoRouters(s.echoServer, s.lspServer, directorySyncServer, oauth2Service, mcpServer, stripeWebhookHandler, profile)
serverStarted = true
return s, nil
diff --git a/backend/store/predefined_roles.go b/backend/store/predefined_roles.go
index 9f81c40d47..a7290cb36d 100644
--- a/backend/store/predefined_roles.go
+++ b/backend/store/predefined_roles.go
@@ -159,6 +159,7 @@ var PredefinedRoles = []*RoleMessage{
permission.WorkspacesGetIamPolicy,
permission.WorkspacesUpdate,
permission.WorkspacesSetIamPolicy,
+ permission.SubscriptionManage,
permission.ServiceAccountsCreate,
permission.ServiceAccountsDelete,
permission.ServiceAccountsGet,
diff --git a/docs/plans/saas/08.in-app-purchase.md b/docs/plans/saas/08.in-app-purchase.md
index 9c7e05c5f7..0b853c3aa0 100644
--- a/docs/plans/saas/08.in-app-purchase.md
+++ b/docs/plans/saas/08.in-app-purchase.md
@@ -382,31 +382,11 @@ func (h *WebhookHandler) HandleCallback(c echo.Context) error {
| `customer.subscription.created` | Extract metadata, update subscription payload with Stripe IDs |
| `customer.subscription.updated` | Map Stripe status → `SubscriptionPayload.Status` |
| `customer.subscription.paused` | Set PAUSED, invalidate license cache |
-| `customer.subscription.resumed` | Set ACTIVE, regenerate + store license |
-| `customer.subscription.deleted` | Set CANCELED, clear license |
-| `invoice.paid` | Update seats/interval from metadata, extend `expires_at`, generate + store license JWT |
+| `customer.subscription.resumed` | Set ACTIVE, invalidate license cache |
+| `customer.subscription.deleted` | Set CANCELED, invalidate license cache |
+| `invoice.paid` | Update seats/interval from metadata, extend `expires_at`, set ACTIVE, invalidate license cache |
-**License activation on `invoice.paid`** (replaces hub's GCP injection):
-
-```go
-func (h *WebhookHandler) activateLicense(ctx context.Context, sub *SubscriptionMessage) error {
- // 1. Build license claims from subscription payload
- claims := &enterprise.Claims{
- Seats: int(sub.Payload.Seat),
- ActiveInstances: int(sub.Payload.InstanceCount),
- Instances: int(sub.Payload.InstanceCount),
- Plan: sub.Payload.Plan.String(),
- WorkspaceID: sub.Workspace,
- }
- // 2. Sign JWT using the license private key
- jwt := h.licenseService.CreateLicense(claims)
- // 3. Store directly via LicenseService
- h.licenseService.StoreLicense(ctx, sub.Workspace, jwt)
- // → This updates the setting table AND invalidates the cache
-}
-```
-
-This is the key simplification: instead of generating a JWT on a remote hub and injecting it via GCP API, we generate and store it in-process.
+**No JWT license generation needed.** The subscription table already has all the data (`plan`, `seat`, `instance_count`, `expires_at`). In SaaS mode, `LicenseService.LoadSubscription` reads directly from the subscription table and converts `SubscriptionPayload` → `v1pb.Subscription`. The webhook handler just updates the subscription table and invalidates the cache.
### 7. Configuration
@@ -490,31 +470,22 @@ func (s *SubscriptionService) ListPlans(ctx, req) {
}
```
-### 9. License Key Management
-
-**Problem**: Hub uses a private key to sign license JWTs. Bytebase uses a public key to verify them. For in-app purchase, Bytebase needs the private key to sign licenses.
+### 9. LicenseService Changes
-**Solution**: Add a `prod.priv.pem` (and `dev.priv.pem`) to `backend/enterprise/keys/`, loaded only when `profile.SaaS == true`.
+In SaaS mode, `LoadSubscription` reads from the `subscription` table instead of parsing a JWT from the `setting` table. No license JWT generation or private key needed.
```go
-type Config struct {
- publicKey *rsa.PublicKey
- privateKey *rsa.PrivateKey // nil for self-hosted
-}
-
-// CreateLicense signs a new license JWT. Only available in SaaS mode.
-func (s *LicenseService) CreateLicense(claims *claims) (string, error) {
- if s.config.privateKey == nil {
- return "", errors.New("license signing not available")
+func (s *LicenseService) LoadSubscription(ctx context.Context, workspaceID string) *v1pb.Subscription {
+ if s.saas {
+ // Read from subscription table, convert SubscriptionPayload → v1pb.Subscription
+ return s.loadSubscriptionFromPurchase(ctx, workspaceID)
}
- token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
- token.Header["kid"] = "v1"
- return token.SignedString(s.config.privateKey)
+ // Self-hosted: existing JWT-based flow (unchanged)
+ return s.loadSubscriptionFromDB(ctx, workspaceID)
}
```
-The private key should be provided via environment variable (not embedded in binary) for security:
-- `LICENSE_PRIVATE_KEY` — PEM-encoded RSA private key, loaded only when `profile.SaaS == true`.
+The conversion is straightforward — map `SubscriptionPayload.Plan` → `v1pb.PlanType`, copy seats/instances/expiry. Cache invalidation works the same way (keyed by workspace ID).
### 10. Frontend Changes
@@ -588,9 +559,9 @@ The `?from=STRIPE` query param triggers the pending payment polling view (same p
### Phase 3: API & Webhooks
6. **Proto definitions** — Add new RPCs and messages to `subscription_service.proto`.
-7. **Subscription service** — Implement `CreatePurchase`, `UpdatePurchase`, `CancelPurchase`, `GetPaymentInfo`, `ListPlans`.
-8. **Stripe webhook** — `backend/api/stripe/webhook.go`, register in `echo_routes.go`.
-9. **License signing** — Add `CreateLicense` to `LicenseService`, load private key in SaaS mode.
+7. **LicenseService SaaS path** — `LoadSubscription` reads from subscription table in SaaS mode. No JWT generation needed.
+8. **Subscription service** — Implement `CreatePurchase`, `UpdatePurchase`, `CancelPurchase`, `GetPaymentInfo`, `ListPlans`.
+9. **Stripe webhook** — `backend/api/stripe/webhook.go`, register in `echo_routes.go`.
10. **SaaS gate** — `UpdateSubscription` blocked in SaaS, purchase APIs blocked in non-SaaS.
### Phase 4: Frontend
@@ -613,10 +584,10 @@ The `?from=STRIPE` query param triggers the pending payment polling view (same p
| Aspect | Hub | Bytebase SaaS |
|--------|-----|----------------|
-| License delivery | JWT download (self-host) or GCP injection (cloud) | In-process `StoreLicense()` |
+| License source | JWT generated by hub, injected via GCP or downloaded | No JWT — `LoadSubscription` reads subscription table directly |
| Instance pricing | Per-instance additional | Fixed 10 instances (TEAM) |
| Payment providers | Stripe + Paddle | Stripe only |
-| Grace period | +7 days (self-host), +12h (cloud) | None needed (instant activation) |
+| Grace period | +7 days (self-host), +12h (cloud) | None needed (same-process read) |
| Subscription owner | `org` entity | `workspace` directly |
| Subscription table | Separate `id` PK, many top-level columns | `workspace` PK, everything in `payload` JSONB |
| Etag | Stored column | Derived from `updated_at` |
@@ -626,8 +597,7 @@ The `?from=STRIPE` query param triggers the pending payment polling view (same p
## Security Considerations
1. **Stripe webhook signature verification** — Must validate `Stripe-Signature` header against `STRIPE_WEBHOOK_SECRET`. Reject unsigned requests.
-2. **License private key** — Environment variable only, never embedded in binary. Only loaded in SaaS mode.
-3. **SaaS gate** — All purchase APIs must check `profile.SaaS` before proceeding. Non-SaaS deployments must never expose Stripe integration.
-4. **Etag-based optimistic locking** — Prevents race conditions on subscription updates. Derived from `updated_at` timestamp.
-5. **Metadata validation** — Webhook handler must verify `source` in metadata to filter out unrelated Stripe events.
-6. **HTTPS only** — Stripe webhooks require HTTPS endpoints.
+2. **SaaS gate** — All purchase APIs must check `profile.SaaS` before proceeding. Non-SaaS deployments must never expose Stripe integration.
+3. **Etag-based optimistic locking** — Prevents race conditions on subscription updates. Derived from `updated_at` timestamp.
+4. **Metadata validation** — Webhook handler must verify `source` in metadata to filter out unrelated Stripe events.
+5. **HTTPS only** — Stripe webhooks require HTTPS endpoints.
diff --git a/frontend/src/types/iam/permission-generated.ts b/frontend/src/types/iam/permission-generated.ts
index 343304c7f0..e252069b93 100644
--- a/frontend/src/types/iam/permission-generated.ts
+++ b/frontend/src/types/iam/permission-generated.ts
@@ -116,6 +116,7 @@ export type Permission =
| "bb.sheets.create"
| "bb.sheets.get"
| "bb.sheets.update"
+ | "bb.subscription.manage"
| "bb.sql.select"
| "bb.sql.ddl"
| "bb.sql.dml"
diff --git a/frontend/src/types/proto-es/v1/subscription_service_pb.d.ts b/frontend/src/types/proto-es/v1/subscription_service_pb.d.ts
index 44c2cfca16..d360062be6 100644
--- a/frontend/src/types/proto-es/v1/subscription_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/subscription_service_pb.d.ts
@@ -47,6 +47,335 @@ export declare type UpdateSubscriptionRequest = Message<"bytebase.v1.UpdateSubsc
*/
export declare const UpdateSubscriptionRequestSchema: GenMessage<UpdateSubscriptionRequest>;
+/**
+ * @generated from message bytebase.v1.CreatePurchaseRequest
+ */
+export declare type CreatePurchaseRequest = Message<"bytebase.v1.CreatePurchaseRequest"> & {
+ /**
+ * @generated from field: bytebase.v1.PlanType plan = 1;
+ */
+ plan: PlanType;
+
+ /**
+ * @generated from field: bytebase.v1.BillingInterval interval = 2;
+ */
+ interval: BillingInterval;
+
+ /**
+ * @generated from field: int32 seats = 3;
+ */
+ seats: number;
+};
+
+/**
+ * Describes the message bytebase.v1.CreatePurchaseRequest.
+ * Use `create(CreatePurchaseRequestSchema)` to create a new message.
+ */
+export declare const CreatePurchaseRequestSchema: GenMessage<CreatePurchaseRequest>;
+
+/**
+ * @generated from message bytebase.v1.CreatePurchaseResponse
+ */
+export declare type CreatePurchaseResponse = Message<"bytebase.v1.CreatePurchaseResponse"> & {
+ /**
+ * Stripe Checkout URL for the user to complete payment.
+ *
+ * @generated from field: string payment_url = 1;
+ */
+ paymentUrl: string;
+};
+
+/**
+ * Describes the message bytebase.v1.CreatePurchaseResponse.
+ * Use `create(CreatePurchaseResponseSchema)` to create a new message.
+ */
+export declare const CreatePurchaseResponseSchema: GenMessage<CreatePurchaseResponse>;
+
+/**
+ * @generated from message bytebase.v1.UpdatePurchaseRequest
+ */
+export declare type UpdatePurchaseRequest = Message<"bytebase.v1.UpdatePurchaseRequest"> & {
+ /**
+ * @generated from field: bytebase.v1.PlanType plan = 1;
+ */
+ plan: PlanType;
+
+ /**
+ * @generated from field: bytebase.v1.BillingInterval interval = 2;
+ */
+ interval: BillingInterval;
+
+ /**
+ * @generated from field: int32 seats = 3;
+ */
+ seats: number;
+
+ /**
+ * @generated from field: string etag = 4;
+ */
+ etag: string;
+};
+
+/**
+ * Describes the message bytebase.v1.UpdatePurchaseRequest.
+ * Use `create(UpdatePurchaseRequestSchema)` to create a new message.
+ */
+export declare const UpdatePurchaseRequestSchema: GenMessage<UpdatePurchaseRequest>;
+
+/**
+ * @generated from message bytebase.v1.UpdatePurchaseResponse
+ */
+export declare type UpdatePurchaseResponse = Message<"bytebase.v1.UpdatePurchaseResponse"> & {
+ /**
+ * If set, redirect to this Stripe Checkout URL.
+ * If empty, the update was applied directly using the existing payment method.
+ *
+ * @generated from field: string payment_url = 1;
+ */
+ paymentUrl: string;
+};
+
+/**
+ * Describes the message bytebase.v1.UpdatePurchaseResponse.
+ * Use `create(UpdatePurchaseResponseSchema)` to create a new message.
+ */
+export declare const UpdatePurchaseResponseSchema: GenMessage<UpdatePurchaseResponse>;
+
+/**
+ * @generated from message bytebase.v1.CancelPurchaseRequest
+ */
+export declare type CancelPurchaseRequest = Message<"bytebase.v1.CancelPurchaseRequest"> & {
+};
+
+/**
+ * Describes the message bytebase.v1.CancelPurchaseRequest.
+ * Use `create(CancelPurchaseRequestSchema)` to create a new message.
+ */
+export declare const CancelPurchaseRequestSchema: GenMessage<CancelPurchaseRequest>;
+
+/**
+ * @generated from message bytebase.v1.CancelPurchaseResponse
+ */
+export declare type CancelPurchaseResponse = Message<"bytebase.v1.CancelPurchaseResponse"> & {
+};
+
+/**
+ * Describes the message bytebase.v1.CancelPurchaseResponse.
+ * Use `create(CancelPurchaseResponseSchema)` to create a new message.
+ */
+export declare const CancelPurchaseResponseSchema: GenMessage<CancelPurchaseResponse>;
+
+/**
+ * @generated from message bytebase.v1.GetPaymentInfoRequest
+ */
+export declare type GetPaymentInfoRequest = Message<"bytebase.v1.GetPaymentInfoRequest"> & {
+};
+
+/**
+ * Describes the message bytebase.v1.GetPaymentInfoRequest.
+ * Use `create(GetPaymentInfoRequestSchema)` to create a new message.
+ */
+export declare const GetPaymentInfoRequestSchema: GenMessage<GetPaymentInfoRequest>;
+
+/**
+ * @generated from message bytebase.v1.PaymentInfo
+ */
+export declare type PaymentInfo = Message<"bytebase.v1.PaymentInfo"> & {
+ /**
+ * @generated from field: string total_price = 1;
+ */
+ totalPrice: string;
+
+ /**
+ * @generated from field: string currency = 2;
+ */
+ currency: string;
+
+ /**
+ * @generated from field: string period_start = 3;
+ */
+ periodStart: string;
+
+ /**
+ * @generated from field: string period_end = 4;
+ */
+ periodEnd: string;
+
+ /**
+ * Stripe Billing Portal URL for invoice management.
+ *
+ * @generated from field: string invoice_url = 5;
+ */
+ invoiceUrl: string;
+};
+
+/**
+ * Describes the message bytebase.v1.PaymentInfo.
+ * Use `create(PaymentInfoSchema)` to create a new message.
+ */
+export declare const PaymentInfoSchema: GenMessage<PaymentInfo>;
+
+/**
+ * @generated from message bytebase.v1.PurchasePlan
+ */
+export declare type PurchasePlan = Message<"bytebase.v1.PurchasePlan"> & {
+ /**
+ * @generated from field: bytebase.v1.PlanType type = 1;
+ */
+ type: PlanType;
+
+ /**
+ * @generated from field: bool self_service_purchase = 2;
+ */
+ selfServicePurchase: boolean;
+
+ /**
+ * @generated from field: repeated bytebase.v1.PurchasePlanAdditional additionals = 3;
+ */
+ additionals: PurchasePlanAdditional[];
+
+ /**
+ * @generated from field: repeated bytebase.v1.PurchaseBillingMethod billing_methods = 4;
+ */
+ billingMethods: PurchaseBillingMethod[];
+};
+
+/**
+ * Describes the message bytebase.v1.PurchasePlan.
+ * Use `create(PurchasePlanSchema)` to create a new message.
+ */
+export declare const PurchasePlanSchema: GenMessage<PurchasePlan>;
+
+/**
+ * @generated from message bytebase.v1.PurchasePlanAdditional
+ */
+export declare type PurchasePlanAdditional = Message<"bytebase.v1.PurchasePlanAdditional"> & {
+ /**
+ * @generated from field: bytebase.v1.PurchasePlanAdditional.Type type = 1;
+ */
+ type: PurchasePlanAdditional_Type;
+
+ /**
+ * Price in USD cents per month.
+ *
+ * @generated from field: int32 unit_price = 2;
+ */
+ unitPrice: number;
+
+ /**
+ * @generated from field: int32 free_count = 3;
+ */
+ freeCount: number;
+
+ /**
+ * @generated from field: int32 minimum_count = 4;
+ */
+ minimumCount: number;
+
+ /**
+ * -1 means unlimited.
+ *
+ * @generated from field: int32 maximum_count = 5;
+ */
+ maximumCount: number;
+};
+
+/**
+ * Describes the message bytebase.v1.PurchasePlanAdditional.
+ * Use `create(PurchasePlanAdditionalSchema)` to create a new message.
+ */
+export declare const PurchasePlanAdditionalSchema: GenMessage<PurchasePlanAdditional>;
+
+/**
+ * @generated from enum bytebase.v1.PurchasePlanAdditional.Type
+ */
+export enum PurchasePlanAdditional_Type {
+ /**
+ * @generated from enum value: TYPE_UNSPECIFIED = 0;
+ */
+ TYPE_UNSPECIFIED = 0,
+
+ /**
+ * @generated from enum value: USER = 1;
+ */
+ USER = 1,
+}
+
+/**
+ * Describes the enum bytebase.v1.PurchasePlanAdditional.Type.
+ */
+export declare const PurchasePlanAdditional_TypeSchema: GenEnum<PurchasePlanAdditional_Type>;
+
+/**
+ * @generated from message bytebase.v1.PurchaseBillingMethod
+ */
+export declare type PurchaseBillingMethod = Message<"bytebase.v1.PurchaseBillingMethod"> & {
+ /**
+ * @generated from field: bytebase.v1.BillingInterval interval = 1;
+ */
+ interval: BillingInterval;
+
+ /**
+ * @generated from field: bytebase.v1.PurchaseDiscount discount = 2;
+ */
+ discount?: PurchaseDiscount;
+};
+
+/**
+ * Describes the message bytebase.v1.PurchaseBillingMethod.
+ * Use `create(PurchaseBillingMethodSchema)` to create a new message.
+ */
+export declare const PurchaseBillingMethodSchema: GenMessage<PurchaseBillingMethod>;
+
+/**
+ * @generated from message bytebase.v1.PurchaseDiscount
+ */
+export declare type PurchaseDiscount = Message<"bytebase.v1.PurchaseDiscount"> & {
+ /**
+ * @generated from field: string description = 1;
+ */
+ description: string;
+
+ /**
+ * @generated from field: string promotion_code = 2;
+ */
+ promotionCode: string;
+};
+
+/**
+ * Describes the message bytebase.v1.PurchaseDiscount.
+ * Use `create(PurchaseDiscountSchema)` to create a new message.
+ */
+export declare const PurchaseDiscountSchema: GenMessage<PurchaseDiscount>;
+
+/**
+ * @generated from message bytebase.v1.ListPurchasePlansRequest
+ */
+export declare type ListPurchasePlansRequest = Message<"bytebase.v1.ListPurchasePlansRequest"> & {
+};
+
+/**
+ * Describes the message bytebase.v1.ListPurchasePlansRequest.
+ * Use `create(ListPurchasePlansRequestSchema)` to create a new message.
+ */
+export declare const ListPurchasePlansRequestSchema: GenMessage<ListPurchasePlansRequest>;
+
+/**
+ * @generated from message bytebase.v1.ListPurchasePlansResponse
+ */
+export declare type ListPurchasePlansResponse = Message<"bytebase.v1.ListPurchasePlansResponse"> & {
+ /**
+ * @generated from field: repeated bytebase.v1.PurchasePlan plans = 1;
+ */
+ plans: PurchasePlan[];
+};
+
+/**
+ * Describes the message bytebase.v1.ListPurchasePlansResponse.
+ * Use `create(ListPurchasePlansResponseSchema)` to create a new message.
+ */
+export declare const ListPurchasePlansResponseSchema: GenMessage<ListPurchasePlansResponse>;
+
/**
* @generated from message bytebase.v1.Subscription
*/
@@ -156,6 +485,31 @@ export declare type PlanLimitConfig = Message<"bytebase.v1.PlanLimitConfig"> & {
*/
export declare const PlanLimitConfigSchema: GenMessage<PlanLimitConfig>;
+/**
+ * @generated from enum bytebase.v1.BillingInterval
+ */
+export enum BillingInterval {
+ /**
+ * @generated from enum value: BILLING_INTERVAL_UNSPECIFIED = 0;
+ */
+ BILLING_INTERVAL_UNSPECIFIED = 0,
+
+ /**
+ * @generated from enum value: MONTH = 1;
+ */
+ MONTH = 1,
+
+ /**
+ * @generated from enum value: YEAR = 2;
+ */
+ YEAR = 2,
+}
+
+/**
+ * Describes the enum bytebase.v1.BillingInterval.
+ */
+export declare const BillingIntervalSchema: GenEnum<BillingInterval>;
+
/**
* @generated from enum bytebase.v1.PlanType
*/
@@ -594,7 +948,7 @@ export declare const SubscriptionService: GenService<{
output: typeof SubscriptionSchema;
},
/**
- * Updates the enterprise license subscription.
+ * Updates the enterprise license subscription (self-hosted only).
* Permissions required: bb.settings.set
*
* @generated from rpc bytebase.v1.SubscriptionService.UpdateSubscription
@@ -604,5 +958,57 @@ export declare const SubscriptionService: GenService<{
input: typeof UpdateSubscriptionRequestSchema;
output: typeof SubscriptionSchema;
},
+ /**
+ * CreatePurchase creates a new subscription purchase (SaaS only).
+ * Returns a Stripe Checkout URL for the user to complete payment.
+ *
+ * @generated from rpc bytebase.v1.SubscriptionService.CreatePurchase
+ */
+ createPurchase: {
+ methodKind: "unary";
+ input: typeof CreatePurchaseRequestSchema;
+ output: typeof CreatePurchaseResponseSchema;
+ },
+ /**
+ * UpdatePurchase updates an existing subscription (SaaS only).
+ * May return a Stripe Checkout URL if payment method change is needed.
+ *
+ * @generated from rpc bytebase.v1.SubscriptionService.UpdatePurchase
+ */
+ updatePurchase: {
+ methodKind: "unary";
+ input: typeof UpdatePurchaseRequestSchema;
+ output: typeof UpdatePurchaseResponseSchema;
+ },
+ /**
+ * CancelPurchase cancels an active subscription (SaaS only).
+ *
+ * @generated from rpc bytebase.v1.SubscriptionService.CancelPurchase
+ */
+ cancelPurchase: {
+ methodKind: "unary";
+ input: typeof CancelPurchaseRequestSchema;
+ output: typeof CancelPurchaseResponseSchema;
+ },
+ /**
+ * GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ *
+ * @generated from rpc bytebase.v1.SubscriptionService.GetPaymentInfo
+ */
+ getPaymentInfo: {
+ methodKind: "unary";
+ input: typeof GetPaymentInfoRequestSchema;
+ output: typeof PaymentInfoSchema;
+ },
+ /**
+ * ListPurchasePlans returns available plans for self-service purchase.
+ *
+ * @generated from rpc bytebase.v1.SubscriptionService.ListPurchasePlans
+ */
+ listPurchasePlans: {
+ methodKind: "unary";
+ input: typeof ListPurchasePlansRequestSchema;
+ output: typeof ListPurchasePlansResponseSchema;
+ },
}>;
diff --git a/frontend/src/types/proto-es/v1/subscription_service_pb.js b/frontend/src/types/proto-es/v1/subscription_service_pb.js
index a638a4f3b2..475f161db0 100644
--- a/frontend/src/types/proto-es/v1/subscription_service_pb.js
+++ b/frontend/src/types/proto-es/v1/subscription_service_pb.js
@@ -13,7 +13,7 @@ import { file_v1_annotation } from "./annotation_pb";
* Describes the file v1/subscription_service.proto.
*/
export const file_v1_subscription_service = /*@__PURE__*/
- fileDesc("Ch12MS9zdWJzY3JpcHRpb25fc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEiGAoWR2V0U3Vic2NyaXB0aW9uUmVxdWVzdCJDChlVcGRhdGVTdWJzY3JpcHRpb25SZXF1ZXN0Eg8KB2xpY2Vuc2UYASABKAkSFQoNYWxsb3dfbWlzc2luZxgCIAEoCCL5AQoMU3Vic2NyaXB0aW9uEigKBHBsYW4YASABKA4yFS5ieXRlYmFzZS52MS5QbGFuVHlwZUID4EEDEhIKBXNlYXRzGAIgASgFQgPgQQMSFgoJaW5zdGFuY2VzGAMgASgFQgPgQQMSHQoQYWN0aXZlX2luc3RhbmNlcxgEIAEoBUID4EEDEjUKDGV4cGlyZXNfdGltZRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBCA+BBAxIVCgh0cmlhbGluZxgGIAEoCEID4EEDEhUKCG9yZ19uYW1lGAcgASgJQgPgQQMSDwoCaGEYCCABKAhCA+BBAyJuCgpQbGFuQ29uZmlnEisKBXBsYW5zGAEgAygLMhwuYnl0ZWJhc2UudjEuUGxhbkxpbWl0Q29uZmlnEjMKEWluc3RhbmNlX2ZlYXR1cmVzGAIgAygOMhguYnl0ZWJhc2UudjEuUGxhbkZlYXR1cmUingEKD1BsYW5MaW1pdENvbmZpZxIjCgR0eXBlGAEgASgOMhUuYnl0ZWJhc2UudjEuUGxhblR5cGUSHgoWbWF4aW11bV9pbnN0YW5jZV9jb3VudBgCIAEoBRIaChJtYXhpbXVtX3NlYXRfY291bnQYAyABKAUSKgoIZmVhdHVyZXMYBCADKA4yGC5ieXRlYmFzZS52MS5QbGFuRmVhdHVyZSpJCghQbGFuVHlwZRIZChVQTEFOX1RZUEVfVU5TUEVDSUZJRUQQABIICgRGUkVFEAESCAoEVEVBTRACEg4KCkVOVEVSUFJJU0UQAyrhEgoLUGxhbkZlYXR1cmUSFwoTRkVBVFVSRV9VTlNQRUNJRklFRBAAEhsKF0ZFQVRVUkVfREFUQUJBU0VfQ0hBTkdFEAESLAooRkVBVFVSRV9HSVRfQkFTRURfU0NIRU1BX1ZFUlNJT05fQ09OVFJPTBACEigKJEZFQVRVUkVfREVDTEFSQVRJVkVfU0NIRU1BX01JR1JBVElPThADEiMKH0ZFQVRVUkVfQ09NUEFSRV9BTkRfU1lOQ19TQ0hFTUEQBBIgChxGRUFUVVJFX09OTElORV9TQ0hFTUFfQ0hBTkdFEAUSJQohRkVBVFVSRV9QUkVfREVQTE9ZTUVOVF9TUUxfUkVWSUVXEAYSMAosRkVBVFVSRV9BVVRPTUFUSUNfQkFDS1VQX0JFRk9SRV9EQVRBX0NIQU5HRVMQBxIjCh9GRUFUVVJFX09ORV9DTElDS19EQVRBX1JPTExCQUNLEAgSKAokRkVBVFVSRV9NVUxUSV9EQVRBQkFTRV9CQVRDSF9DSEFOR0VTEAkSLgoqRkVBVFVSRV9QUk9HUkVTU0lWRV9FTlZJUk9OTUVOVF9ERVBMT1lNRU5UEAoSIgoeRkVBVFVSRV9TQ0hFRFVMRURfUk9MTE9VVF9USU1FEAsSHgoaRkVBVFVSRV9EQVRBQkFTRV9DSEFOR0VMT0cQDBIiCh5GRUFUVVJFX1NDSEVNQV9EUklGVF9ERVRFQ1RJT04QDRIaChZGRUFUVVJFX1JPTExPVVRfUE9MSUNZEA4SIAocRkVBVFVSRV9XRUJfQkFTRURfU1FMX0VESVRPUhAPEiEKHUZFQVRVUkVfU1FMX0VESVRPUl9BRE1JTl9NT0RFEBASIwofRkVBVFVSRV9OQVRVUkFMX0xBTkdVQUdFX1RPX1NRTBAREiAKHEZFQVRVUkVfQUlfUVVFUllfRVhQTEFOQVRJT04QEhIgChxGRUFUVVJFX0FJX1FVRVJZX1NVR0dFU1RJT05TEBMSGQoVRkVBVFVSRV9BVVRPX0NPTVBMRVRFEBQSGgoWRkVBVFVSRV9TQ0hFTUFfRElBR1JBTRAVEhkKFUZFQVRVUkVfU0NIRU1BX0VESVRPUhAWEhcKE0ZFQVRVUkVfREFUQV9FWFBPUlQQFxIfChtGRUFUVVJFX0RBVEFfT0ZGTElORV9FWFBPUlQQGBIZChVGRUFUVVJFX1FVRVJZX0hJU1RPUlkQGRIoCiRGRUFUVVJFX1NBVkVEX0FORF9TSEFSRURfU1FMX1NDUklQVFMQGhIXChNGRUFUVVJFX0JBVENIX1FVRVJZEBsSKQolRkVBVFVSRV9JTlNUQU5DRV9SRUFEX09OTFlfQ09OTkVDVElPThAcEhgKFEZFQVRVUkVfUVVFUllfUE9MSUNZEB0SIQodRkVBVFVSRV9SRVNUUklDVF9DT1BZSU5HX0RBVEEQHhIPCgtGRUFUVVJFX0lBTRAfEiMKH0ZFQVRVUkVfSU5TVEFOQ0VfU1NMX0NPTk5FQ1RJT04QIBIvCitGRUFUVVJFX0lOU1RBTkNFX0NPTk5FQ1RJT05fT1ZFUl9TU0hfVFVOTkVMECESMgouRkVBVFVSRV9JTlNUQU5DRV9DT05ORUNUSU9OX0lBTV9BVVRIRU5USUNBVElPThAiEiEKHUZFQVRVUkVfR09PR0xFX0FORF9HSVRIVUJfU1NPECMSFwoTRkVBVFVSRV9VU0VSX0dST1VQUxAkEigKJEZFQVRVUkVfRElTQUxMT1dfU0VMRl9TRVJWSUNFX1NJR05VUBAlEiUKIUZFQVRVUkVfQ1VTVE9NX0lOU1RBTkNFX1NZTkNfVElNRRAmEiwKKEZFQVRVUkVfQ1VTVE9NX0lOU1RBTkNFX0NPTk5FQ1RJT05fTElNSVQQJxIbChdGRUFUVVJFX1JJU0tfQVNTRVNTTUVOVBAoEh0KGUZFQVRVUkVfQVBQUk9WQUxfV09SS0ZMT1cQKRIVChFGRUFUVVJFX0FVRElUX0xPRxAqEhoKFkZFQVRVUkVfRU5URVJQUklTRV9TU08QKxISCg5GRUFUVVJFX1RXT19GQRAsEiEKHUZFQVRVUkVfUEFTU1dPUkRfUkVTVFJJQ1RJT05TEC0SJAogRkVBVFVSRV9ESVNBTExPV19QQVNTV09SRF9TSUdOSU4QLhIYChRGRUFUVVJFX0NVU1RPTV9ST0xFUxAvEiEKHUZFQVRVUkVfUkVRVUVTVF9ST0xFX1dPUktGTE9XEDASDwoLRkVBVFVSRV9KSVQQMRIYChRGRUFUVVJFX0RBVEFfTUFTS0lORxAyEh8KG0ZFQVRVUkVfREFUQV9DTEFTU0lGSUNBVElPThAzEhAKDEZFQVRVUkVfU0NJTRA0EhoKFkZFQVRVUkVfRElSRUNUT1JZX1NZTkMQNRIiCh5GRUFUVVJFX1RPS0VOX0RVUkFUSU9OX0NPTlRST0wQNhIjCh9GRUFUVVJFX0VYVEVSTkFMX1NFQ1JFVF9NQU5BR0VSEDcSKQolRkVBVFVSRV9VU0VSX0VNQUlMX0RPTUFJTl9SRVNUUklDVElPThA4Eh4KGkZFQVRVUkVfUFJPSkVDVF9NQU5BR0VNRU5UEDkSIgoeRkVBVFVSRV9FTlZJUk9OTUVOVF9NQU5BR0VNRU5UEDoSHAoYRkVBVFVSRV9JTV9OT1RJRklDQVRJT05TEDsSHgoaRkVBVFVSRV9URVJSQUZPUk1fUFJPVklERVIQPBIbChdGRUFUVVJFX0RBVEFCQVNFX0dST1VQUxA9Eh0KGUZFQVRVUkVfRU5WSVJPTk1FTlRfVElFUlMQPhIiCh5GRUFUVVJFX0RBU0hCT0FSRF9BTk5PVU5DRU1FTlQQPxIkCiBGRUFUVVJFX0FQSV9JTlRFR1JBVElPTl9HVUlEQU5DRRBAEhcKE0ZFQVRVUkVfQ1VTVE9NX0xPR08QQRIVChFGRUFUVVJFX1dBVEVSTUFSSxBCEiIKHkZFQVRVUkVfUk9BRE1BUF9QUklPUklUSVpBVElPThBDEhYKEkZFQVRVUkVfQ1VTVE9NX01TQRBEEh0KGUZFQVRVUkVfQ09NTVVOSVRZX1NVUFBPUlQQRRIZChVGRUFUVVJFX0VNQUlMX1NVUFBPUlQQRhImCiJGRUFUVVJFX0RFRElDQVRFRF9TVVBQT1JUX1dJVEhfU0xBEEcypQIKE1N1YnNjcmlwdGlvblNlcnZpY2UScgoPR2V0U3Vic2NyaXB0aW9uEiMuYnl0ZWJhc2UudjEuR2V0U3Vic2NyaXB0aW9uUmVxdWVzdBoZLmJ5dGViYXNlLnYxLlN1YnNjcmlwdGlvbiIf2kEAgOowAYLT5JMCEhIQL3YxL3N1YnNjcmlwdGlvbhKZAQoSVXBkYXRlU3Vic2NyaXB0aW9uEiYuYnl0ZWJhc2UudjEuVXBkYXRlU3Vic2NyaXB0aW9uUmVxdWVzdBoZLmJ5dGViYXNlLnYxLlN1YnNjcmlwdGlvbiJA2kEFcGF0Y2iK6jAPYmIuc2V0dGluZ3Muc2V0kOowAYLT5JMCGzoHbGljZW5zZTIQL3YxL3N1YnNjcmlwdGlvbkKuAQoPY29tLmJ5dGViYXNlLnYxQhhTdWJzY3JpcHRpb25TZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_protobuf_timestamp, file_v1_annotation]);
+ fileDesc("Ch12MS9zdWJzY3JpcHRpb25fc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEiGAoWR2V0U3Vic2NyaXB0aW9uUmVxdWVzdCJDChlVcGRhdGVTdWJzY3JpcHRpb25SZXF1ZXN0Eg8KB2xpY2Vuc2UYASABKAkSFQoNYWxsb3dfbWlzc2luZxgCIAEoCCJ7ChVDcmVhdGVQdXJjaGFzZVJlcXVlc3QSIwoEcGxhbhgBIAEoDjIVLmJ5dGViYXNlLnYxLlBsYW5UeXBlEi4KCGludGVydmFsGAIgASgOMhwuYnl0ZWJhc2UudjEuQmlsbGluZ0ludGVydmFsEg0KBXNlYXRzGAMgASgFIi0KFkNyZWF0ZVB1cmNoYXNlUmVzcG9uc2USEwoLcGF5bWVudF91cmwYASABKAkiiQEKFVVwZGF0ZVB1cmNoYXNlUmVxdWVzdBIjCgRwbGFuGAEgASgOMhUuYnl0ZWJhc2UudjEuUGxhblR5cGUSLgoIaW50ZXJ2YWwYAiABKA4yHC5ieXRlYmFzZS52MS5CaWxsaW5nSW50ZXJ2YWwSDQoFc2VhdHMYAyABKAUSDAoEZXRhZxgEIAEoCSItChZVcGRhdGVQdXJjaGFzZVJlc3BvbnNlEhMKC3BheW1lbnRfdXJsGAEgASgJIhcKFUNhbmNlbFB1cmNoYXNlUmVxdWVzdCIYChZDYW5jZWxQdXJjaGFzZVJlc3BvbnNlIhcKFUdldFBheW1lbnRJbmZvUmVxdWVzdCJzCgtQYXltZW50SW5mbxITCgt0b3RhbF9wcmljZRgBIAEoCRIQCghjdXJyZW5jeRgCIAEoCRIUCgxwZXJpb2Rfc3RhcnQYAyABKAkSEgoKcGVyaW9kX2VuZBgEIAEoCRITCgtpbnZvaWNlX3VybBgFIAEoCSLJAQoMUHVyY2hhc2VQbGFuEiMKBHR5cGUYASABKA4yFS5ieXRlYmFzZS52MS5QbGFuVHlwZRIdChVzZWxmX3NlcnZpY2VfcHVyY2hhc2UYAiABKAgSOAoLYWRkaXRpb25hbHMYAyADKAsyIy5ieXRlYmFzZS52MS5QdXJjaGFzZVBsYW5BZGRpdGlvbmFsEjsKD2JpbGxpbmdfbWV0aG9kcxgEIAMoCzIiLmJ5dGViYXNlLnYxLlB1cmNoYXNlQmlsbGluZ01ldGhvZCLOAQoWUHVyY2hhc2VQbGFuQWRkaXRpb25hbBI2CgR0eXBlGAEgASgOMiguYnl0ZWJhc2UudjEuUHVyY2hhc2VQbGFuQWRkaXRpb25hbC5UeXBlEhIKCnVuaXRfcHJpY2UYAiABKAUSEgoKZnJlZV9jb3VudBgDIAEoBRIVCg1taW5pbXVtX2NvdW50GAQgASgFEhUKDW1heGltdW1fY291bnQYBSABKAUiJgoEVHlwZRIUChBUWVBFX1VOU1BFQ0lGSUVEEAASCAoEVVNFUhABIngKFVB1cmNoYXNlQmlsbGluZ01ldGhvZBIuCghpbnRlcnZhbBgBIAEoDjIcLmJ5dGViYXNlLnYxLkJpbGxpbmdJbnRlcnZhbBIvCghkaXNjb3VudBgCIAEoCzIdLmJ5dGViYXNlLnYxLlB1cmNoYXNlRGlzY291bnQiPwoQUHVyY2hhc2VEaXNjb3VudBITCgtkZXNjcmlwdGlvbhgBIAEoCRIWCg5wcm9tb3Rpb25fY29kZRgCIAEoCSIaChhMaXN0UHVyY2hhc2VQbGFuc1JlcXVlc3QiRQoZTGlzdFB1cmNoYXNlUGxhbnNSZXNwb25zZRIoCgVwbGFucxgBIAMoCzIZLmJ5dGViYXNlLnYxLlB1cmNoYXNlUGxhbiL5AQoMU3Vic2NyaXB0aW9uEigKBHBsYW4YASABKA4yFS5ieXRlYmFzZS52MS5QbGFuVHlwZUID4EEDEhIKBXNlYXRzGAIgASgFQgPgQQMSFgoJaW5zdGFuY2VzGAMgASgFQgPgQQMSHQoQYWN0aXZlX2luc3RhbmNlcxgEIAEoBUID4EEDEjUKDGV4cGlyZXNfdGltZRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBCA+BBAxIVCgh0cmlhbGluZxgGIAEoCEID4EEDEhUKCG9yZ19uYW1lGAcgASgJQgPgQQMSDwoCaGEYCCABKAhCA+BBAyJuCgpQbGFuQ29uZmlnEisKBXBsYW5zGAEgAygLMhwuYnl0ZWJhc2UudjEuUGxhbkxpbWl0Q29uZmlnEjMKEWluc3RhbmNlX2ZlYXR1cmVzGAIgAygOMhguYnl0ZWJhc2UudjEuUGxhbkZlYXR1cmUingEKD1BsYW5MaW1pdENvbmZpZxIjCgR0eXBlGAEgASgOMhUuYnl0ZWJhc2UudjEuUGxhblR5cGUSHgoWbWF4aW11bV9pbnN0YW5jZV9jb3VudBgCIAEoBRIaChJtYXhpbXVtX3NlYXRfY291bnQYAyABKAUSKgoIZmVhdHVyZXMYBCADKA4yGC5ieXRlYmFzZS52MS5QbGFuRmVhdHVyZSpICg9CaWxsaW5nSW50ZXJ2YWwSIAocQklMTElOR19JTlRFUlZBTF9VTlNQRUNJRklFRBAAEgkKBU1PTlRIEAESCAoEWUVBUhACKkkKCFBsYW5UeXBlEhkKFVBMQU5fVFlQRV9VTlNQRUNJRklFRBAAEggKBEZSRUUQARIICgRURUFNEAISDgoKRU5URVJQUklTRRADKuESCgtQbGFuRmVhdHVyZRIXChNGRUFUVVJFX1VOU1BFQ0lGSUVEEAASGwoXRkVBVFVSRV9EQVRBQkFTRV9DSEFOR0UQARIsCihGRUFUVVJFX0dJVF9CQVNFRF9TQ0hFTUFfVkVSU0lPTl9DT05UUk9MEAISKAokRkVBVFVSRV9ERUNMQVJBVElWRV9TQ0hFTUFfTUlHUkFUSU9OEAMSIwofRkVBVFVSRV9DT01QQVJFX0FORF9TWU5DX1NDSEVNQRAEEiAKHEZFQVRVUkVfT05MSU5FX1NDSEVNQV9DSEFOR0UQBRIlCiFGRUFUVVJFX1BSRV9ERVBMT1lNRU5UX1NRTF9SRVZJRVcQBhIwCixGRUFUVVJFX0FVVE9NQVRJQ19CQUNLVVBfQkVGT1JFX0RBVEFfQ0hBTkdFUxAHEiMKH0ZFQVRVUkVfT05FX0NMSUNLX0RBVEFfUk9MTEJBQ0sQCBIoCiRGRUFUVVJFX01VTFRJX0RBVEFCQVNFX0JBVENIX0NIQU5HRVMQCRIuCipGRUFUVVJFX1BST0dSRVNTSVZFX0VOVklST05NRU5UX0RFUExPWU1FTlQQChIiCh5GRUFUVVJFX1NDSEVEVUxFRF9ST0xMT1VUX1RJTUUQCxIeChpGRUFUVVJFX0RBVEFCQVNFX0NIQU5HRUxPRxAMEiIKHkZFQVRVUkVfU0NIRU1BX0RSSUZUX0RFVEVDVElPThANEhoKFkZFQVRVUkVfUk9MTE9VVF9QT0xJQ1kQDhIgChxGRUFUVVJFX1dFQl9CQVNFRF9TUUxfRURJVE9SEA8SIQodRkVBVFVSRV9TUUxfRURJVE9SX0FETUlOX01PREUQEBIjCh9GRUFUVVJFX05BVFVSQUxfTEFOR1VBR0VfVE9fU1FMEBESIAocRkVBVFVSRV9BSV9RVUVSWV9FWFBMQU5BVElPThASEiAKHEZFQVRVUkVfQUlfUVVFUllfU1VHR0VTVElPTlMQExIZChVGRUFUVVJFX0FVVE9fQ09NUExFVEUQFBIaChZGRUFUVVJFX1NDSEVNQV9ESUFHUkFNEBUSGQoVRkVBVFVSRV9TQ0hFTUFfRURJVE9SEBYSFwoTRkVBVFVSRV9EQVRBX0VYUE9SVBAXEh8KG0ZFQVRVUkVfREFUQV9PRkZMSU5FX0VYUE9SVBAYEhkKFUZFQVRVUkVfUVVFUllfSElTVE9SWRAZEigKJEZFQVRVUkVfU0FWRURfQU5EX1NIQVJFRF9TUUxfU0NSSVBUUxAaEhcKE0ZFQVRVUkVfQkFUQ0hfUVVFUlkQGxIpCiVGRUFUVVJFX0lOU1RBTkNFX1JFQURfT05MWV9DT05ORUNUSU9OEBwSGAoURkVBVFVSRV9RVUVSWV9QT0xJQ1kQHRIhCh1GRUFUVVJFX1JFU1RSSUNUX0NPUFlJTkdfREFUQRAeEg8KC0ZFQVRVUkVfSUFNEB8SIwofRkVBVFVSRV9JTlNUQU5DRV9TU0xfQ09OTkVDVElPThAgEi8KK0ZFQVRVUkVfSU5TVEFOQ0VfQ09OTkVDVElPTl9PVkVSX1NTSF9UVU5ORUwQIRIyCi5GRUFUVVJFX0lOU1RBTkNFX0NPTk5FQ1RJT05fSUFNX0FVVEhFTlRJQ0FUSU9OECISIQodRkVBVFVSRV9HT09HTEVfQU5EX0dJVEhVQl9TU08QIxIXChNGRUFUVVJFX1VTRVJfR1JPVVBTECQSKAokRkVBVFVSRV9ESVNBTExPV19TRUxGX1NFUlZJQ0VfU0lHTlVQECUSJQohRkVBVFVSRV9DVVNUT01fSU5TVEFOQ0VfU1lOQ19USU1FECYSLAooRkVBVFVSRV9DVVNUT01fSU5TVEFOQ0VfQ09OTkVDVElPTl9MSU1JVBAnEhsKF0ZFQVRVUkVfUklTS19BU1NFU1NNRU5UECgSHQoZRkVBVFVSRV9BUFBST1ZBTF9XT1JLRkxPVxApEhUKEUZFQVRVUkVfQVVESVRfTE9HECoSGgoWRkVBVFVSRV9FTlRFUlBSSVNFX1NTTxArEhIKDkZFQVRVUkVfVFdPX0ZBECwSIQodRkVBVFVSRV9QQVNTV09SRF9SRVNUUklDVElPTlMQLRIkCiBGRUFUVVJFX0RJU0FMTE9XX1BBU1NXT1JEX1NJR05JThAuEhgKFEZFQVRVUkVfQ1VTVE9NX1JPTEVTEC8SIQodRkVBVFVSRV9SRVFVRVNUX1JPTEVfV09SS0ZMT1cQMBIPCgtGRUFUVVJFX0pJVBAxEhgKFEZFQVRVUkVfREFUQV9NQVNLSU5HEDISHwobRkVBVFVSRV9EQVRBX0NMQVNTSUZJQ0FUSU9OEDMSEAoMRkVBVFVSRV9TQ0lNEDQSGgoWRkVBVFVSRV9ESVJFQ1RPUllfU1lOQxA1EiIKHkZFQVRVUkVfVE9LRU5fRFVSQVRJT05fQ09OVFJPTBA2EiMKH0ZFQVRVUkVfRVhURVJOQUxfU0VDUkVUX01BTkFHRVIQNxIpCiVGRUFUVVJFX1VTRVJfRU1BSUxfRE9NQUlOX1JFU1RSSUNUSU9OEDgSHgoaRkVBVFVSRV9QUk9KRUNUX01BTkFHRU1FTlQQORIiCh5GRUFUVVJFX0VOVklST05NRU5UX01BTkFHRU1FTlQQOhIcChhGRUFUVVJFX0lNX05PVElGSUNBVElPTlMQOxIeChpGRUFUVVJFX1RFUlJBRk9STV9QUk9WSURFUhA8EhsKF0ZFQVRVUkVfREFUQUJBU0VfR1JPVVBTED0SHQoZRkVBVFVSRV9FTlZJUk9OTUVOVF9USUVSUxA+EiIKHkZFQVRVUkVfREFTSEJPQVJEX0FOTk9VTkNFTUVOVBA/EiQKIEZFQVRVUkVfQVBJX0lOVEVHUkFUSU9OX0dVSURBTkNFEEASFwoTRkVBVFVSRV9DVVNUT01fTE9HTxBBEhUKEUZFQVRVUkVfV0FURVJNQVJLEEISIgoeRkVBVFVSRV9ST0FETUFQX1BSSU9SSVRJWkFUSU9OEEMSFgoSRkVBVFVSRV9DVVNUT01fTVNBEEQSHQoZRkVBVFVSRV9DT01NVU5JVFlfU1VQUE9SVBBFEhkKFUZFQVRVUkVfRU1BSUxfU1VQUE9SVBBGEiYKIkZFQVRVUkVfREVESUNBVEVEX1NVUFBPUlRfV0lUSF9TTEEQRzKvCAoTU3Vic2NyaXB0aW9uU2VydmljZRJyCg9HZXRTdWJzY3JpcHRpb24SIy5ieXRlYmFzZS52MS5HZXRTdWJzY3JpcHRpb25SZXF1ZXN0GhkuYnl0ZWJhc2UudjEuU3Vic2NyaXB0aW9uIh/aQQCA6jABgtPkkwISEhAvdjEvc3Vic2NyaXB0aW9uEpkBChJVcGRhdGVTdWJzY3JpcHRpb24SJi5ieXRlYmFzZS52MS5VcGRhdGVTdWJzY3JpcHRpb25SZXF1ZXN0GhkuYnl0ZWJhc2UudjEuU3Vic2NyaXB0aW9uIkDaQQVwYXRjaIrqMA9iYi5zZXR0aW5ncy5zZXSQ6jABgtPkkwIbOgdsaWNlbnNlMhAvdjEvc3Vic2NyaXB0aW9uEp0BCg5DcmVhdGVQdXJjaGFzZRIiLmJ5dGViYXNlLnYxLkNyZWF0ZVB1cmNoYXNlUmVxdWVzdBojLmJ5dGViYXNlLnYxLkNyZWF0ZVB1cmNoYXNlUmVzcG9uc2UiQorqMBZiYi5zdWJzY3JpcHRpb24ubWFuYWdlkOowAYLT5JMCHjoBKiIZL3YxL3N1YnNjcmlwdGlvbjpwdXJjaGFzZRKjAQoOVXBkYXRlUHVyY2hhc2USIi5ieXRlYmFzZS52MS5VcGRhdGVQdXJjaGFzZVJlcXVlc3QaIy5ieXRlYmFzZS52MS5VcGRhdGVQdXJjaGFzZVJlc3BvbnNlIkiK6jAWYmIuc3Vic2NyaXB0aW9uLm1hbmFnZZDqMAGC0+STAiQ6ASoiHy92MS9zdWJzY3JpcHRpb246dXBkYXRlUHVyY2hhc2USowEKDkNhbmNlbFB1cmNoYXNlEiIuYnl0ZWJhc2UudjEuQ2FuY2VsUHVyY2hhc2VSZXF1ZXN0GiMuYnl0ZWJhc2UudjEuQ2FuY2VsUHVyY2hhc2VSZXNwb25zZSJIiuowFmJiLnN1YnNjcmlwdGlvbi5tYW5hZ2WQ6jABgtPkkwIkOgEqIh8vdjEvc3Vic2NyaXB0aW9uOmNhbmNlbFB1cmNoYXNlEpIBCg5HZXRQYXltZW50SW5mbxIiLmJ5dGViYXNlLnYxLkdldFBheW1lbnRJbmZvUmVxdWVzdBoYLmJ5dGViYXNlLnYxLlBheW1lbnRJbmZvIkKK6jAWYmIuc3Vic2NyaXB0aW9uLm1hbmFnZZDqMAGC0+STAh4SHC92MS9zdWJzY3JpcHRpb24vcGF5bWVudEluZm8ShgEKEUxpc3RQdXJjaGFzZVBsYW5zEiUuYnl0ZWJhc2UudjEuTGlzdFB1cmNoYXNlUGxhbnNSZXF1ZXN0GiYuYnl0ZWJhc2UudjEuTGlzdFB1cmNoYXNlUGxhbnNSZXNwb25zZSIigOowAYLT5JMCGBIWL3YxL3N1YnNjcmlwdGlvbi9wbGFuc0KuAQoPY29tLmJ5dGViYXNlLnYxQhhTdWJzY3JpcHRpb25TZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_protobuf_timestamp, file_v1_annotation]);
/**
* Describes the message bytebase.v1.GetSubscriptionRequest.
@@ -29,32 +29,154 @@ export const GetSubscriptionRequestSchema = /*@__PURE__*/
export const UpdateSubscriptionRequestSchema = /*@__PURE__*/
messageDesc(file_v1_subscription_service, 1);
+/**
+ * Describes the message bytebase.v1.CreatePurchaseRequest.
+ * Use `create(CreatePurchaseRequestSchema)` to create a new message.
+ */
+export const CreatePurchaseRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 2);
+
+/**
+ * Describes the message bytebase.v1.CreatePurchaseResponse.
+ * Use `create(CreatePurchaseResponseSchema)` to create a new message.
+ */
+export const CreatePurchaseResponseSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 3);
+
+/**
+ * Describes the message bytebase.v1.UpdatePurchaseRequest.
+ * Use `create(UpdatePurchaseRequestSchema)` to create a new message.
+ */
+export const UpdatePurchaseRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 4);
+
+/**
+ * Describes the message bytebase.v1.UpdatePurchaseResponse.
+ * Use `create(UpdatePurchaseResponseSchema)` to create a new message.
+ */
+export const UpdatePurchaseResponseSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 5);
+
+/**
+ * Describes the message bytebase.v1.CancelPurchaseRequest.
+ * Use `create(CancelPurchaseRequestSchema)` to create a new message.
+ */
+export const CancelPurchaseRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 6);
+
+/**
+ * Describes the message bytebase.v1.CancelPurchaseResponse.
+ * Use `create(CancelPurchaseResponseSchema)` to create a new message.
+ */
+export const CancelPurchaseResponseSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 7);
+
+/**
+ * Describes the message bytebase.v1.GetPaymentInfoRequest.
+ * Use `create(GetPaymentInfoRequestSchema)` to create a new message.
+ */
+export const GetPaymentInfoRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 8);
+
+/**
+ * Describes the message bytebase.v1.PaymentInfo.
+ * Use `create(PaymentInfoSchema)` to create a new message.
+ */
+export const PaymentInfoSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 9);
+
+/**
+ * Describes the message bytebase.v1.PurchasePlan.
+ * Use `create(PurchasePlanSchema)` to create a new message.
+ */
+export const PurchasePlanSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 10);
+
+/**
+ * Describes the message bytebase.v1.PurchasePlanAdditional.
+ * Use `create(PurchasePlanAdditionalSchema)` to create a new message.
+ */
+export const PurchasePlanAdditionalSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 11);
+
+/**
+ * Describes the enum bytebase.v1.PurchasePlanAdditional.Type.
+ */
+export const PurchasePlanAdditional_TypeSchema = /*@__PURE__*/
+ enumDesc(file_v1_subscription_service, 11, 0);
+
+/**
+ * @generated from enum bytebase.v1.PurchasePlanAdditional.Type
+ */
+export const PurchasePlanAdditional_Type = /*@__PURE__*/
+ tsEnum(PurchasePlanAdditional_TypeSchema);
+
+/**
+ * Describes the message bytebase.v1.PurchaseBillingMethod.
+ * Use `create(PurchaseBillingMethodSchema)` to create a new message.
+ */
+export const PurchaseBillingMethodSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 12);
+
+/**
+ * Describes the message bytebase.v1.PurchaseDiscount.
+ * Use `create(PurchaseDiscountSchema)` to create a new message.
+ */
+export const PurchaseDiscountSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 13);
+
+/**
+ * Describes the message bytebase.v1.ListPurchasePlansRequest.
+ * Use `create(ListPurchasePlansRequestSchema)` to create a new message.
+ */
+export const ListPurchasePlansRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 14);
+
+/**
+ * Describes the message bytebase.v1.ListPurchasePlansResponse.
+ * Use `create(ListPurchasePlansResponseSchema)` to create a new message.
+ */
+export const ListPurchasePlansResponseSchema = /*@__PURE__*/
+ messageDesc(file_v1_subscription_service, 15);
+
/**
* Describes the message bytebase.v1.Subscription.
* Use `create(SubscriptionSchema)` to create a new message.
*/
export const SubscriptionSchema = /*@__PURE__*/
- messageDesc(file_v1_subscription_service, 2);
+ messageDesc(file_v1_subscription_service, 16);
/**
* Describes the message bytebase.v1.PlanConfig.
* Use `create(PlanConfigSchema)` to create a new message.
*/
export const PlanConfigSchema = /*@__PURE__*/
- messageDesc(file_v1_subscription_service, 3);
+ messageDesc(file_v1_subscription_service, 17);
/**
* Describes the message bytebase.v1.PlanLimitConfig.
* Use `create(PlanLimitConfigSchema)` to create a new message.
*/
export const PlanLimitConfigSchema = /*@__PURE__*/
- messageDesc(file_v1_subscription_service, 4);
+ messageDesc(file_v1_subscription_service, 18);
+
+/**
+ * Describes the enum bytebase.v1.BillingInterval.
+ */
+export const BillingIntervalSchema = /*@__PURE__*/
+ enumDesc(file_v1_subscription_service, 0);
+
+/**
+ * @generated from enum bytebase.v1.BillingInterval
+ */
+export const BillingInterval = /*@__PURE__*/
+ tsEnum(BillingIntervalSchema);
/**
* Describes the enum bytebase.v1.PlanType.
*/
export const PlanTypeSchema = /*@__PURE__*/
- enumDesc(file_v1_subscription_service, 0);
+ enumDesc(file_v1_subscription_service, 1);
/**
* @generated from enum bytebase.v1.PlanType
@@ -66,7 +188,7 @@ export const PlanType = /*@__PURE__*/
* Describes the enum bytebase.v1.PlanFeature.
*/
export const PlanFeatureSchema = /*@__PURE__*/
- enumDesc(file_v1_subscription_service, 1);
+ enumDesc(file_v1_subscription_service, 2);
/**
* PlanFeature represents the available features in Bytebase
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 9b7ec93a42..755300a25a 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -14117,7 +14117,7 @@ paths:
- SubscriptionService
summary: UpdateSubscription
description: |-
- Updates the enterprise license subscription.
+ Updates the enterprise license subscription (self-hosted only).
Permissions required: bb.settings.set
operationId: SubscriptionService_UpdateSubscription
parameters:
@@ -14145,6 +14145,98 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Subscription'
+ /v1/subscription/paymentInfo:
+ get:
+ tags:
+ - SubscriptionService
+ summary: GetPaymentInfo
+ description: GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ operationId: SubscriptionService_GetPaymentInfo
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.PaymentInfo'
+ /v1/subscription/plans:
+ get:
+ tags:
+ - SubscriptionService
+ summary: ListPurchasePlans
+ description: ListPurchasePlans returns available plans for self-service purchase.
+ operationId: SubscriptionService_ListPurchasePlans
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.ListPurchasePlansResponse'
+ /v1/subscription:cancelPurchase:
+ post:
+ tags:
+ - SubscriptionService
+ summary: CancelPurchase
+ description: CancelPurchase cancels an active subscription (SaaS only).
+ operationId: SubscriptionService_CancelPurchase
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CancelPurchaseRequest'
+ required: true
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CancelPurchaseResponse'
+ /v1/subscription:purchase:
+ post:
+ tags:
+ - SubscriptionService
+ summary: CreatePurchase
+ description: |-
+ CreatePurchase creates a new subscription purchase (SaaS only).
+ Returns a Stripe Checkout URL for the user to complete payment.
+ operationId: SubscriptionService_CreatePurchase
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CreatePurchaseRequest'
+ required: true
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.CreatePurchaseResponse'
+ /v1/subscription:updatePurchase:
+ post:
+ tags:
+ - SubscriptionService
+ summary: UpdatePurchase
+ description: |-
+ UpdatePurchase updates an existing subscription (SaaS only).
+ May return a Stripe Checkout URL if payment method change is needed.
+ operationId: SubscriptionService_UpdatePurchase
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.UpdatePurchaseRequest'
+ required: true
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.UpdatePurchaseResponse'
/v1/users:
get:
tags:
@@ -17672,6 +17764,13 @@ components:
title: worksheet_organizers
title: BatchUpdateWorksheetOrganizerResponse
additionalProperties: false
+ bytebase.v1.BillingInterval:
+ type: string
+ title: BillingInterval
+ enum:
+ - BILLING_INTERVAL_UNSPECIFIED
+ - MONTH
+ - YEAR
bytebase.v1.Binding:
type: object
properties:
@@ -17796,6 +17895,14 @@ components:
type: object
title: CancelPlanCheckRunResponse
additionalProperties: false
+ bytebase.v1.CancelPurchaseRequest:
+ type: object
+ title: CancelPurchaseRequest
+ additionalProperties: false
+ bytebase.v1.CancelPurchaseResponse:
+ type: object
+ title: CancelPurchaseResponse
+ additionalProperties: false
bytebase.v1.Changelog:
type: object
properties:
@@ -18318,6 +18425,30 @@ components:
required:
- project
additionalProperties: false
+ bytebase.v1.CreatePurchaseRequest:
+ type: object
+ properties:
+ plan:
+ title: plan
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ seats:
+ type: integer
+ title: seats
+ format: int32
+ title: CreatePurchaseRequest
+ additionalProperties: false
+ bytebase.v1.CreatePurchaseResponse:
+ type: object
+ properties:
+ paymentUrl:
+ type: string
+ title: payment_url
+ description: Stripe Checkout URL for the user to complete payment.
+ title: CreatePurchaseResponse
+ additionalProperties: false
bytebase.v1.CreateReleaseRequest:
type: object
properties:
@@ -20371,6 +20502,10 @@ components:
required:
- name
additionalProperties: false
+ bytebase.v1.GetPaymentInfoRequest:
+ type: object
+ title: GetPaymentInfoRequest
+ additionalProperties: false
bytebase.v1.GetPlanCheckRunRequest:
type: object
properties:
@@ -22383,6 +22518,20 @@ components:
If this field is omitted, there are no subsequent pages.
title: ListProjectsResponse
additionalProperties: false
+ bytebase.v1.ListPurchasePlansRequest:
+ type: object
+ title: ListPurchasePlansRequest
+ additionalProperties: false
+ bytebase.v1.ListPurchasePlansResponse:
+ type: object
+ properties:
+ plans:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlan'
+ title: plans
+ title: ListPurchasePlansResponse
+ additionalProperties: false
bytebase.v1.ListReleaseCategoriesRequest:
type: object
properties:
@@ -23351,6 +23500,27 @@ components:
title: PackageMetadata
additionalProperties: false
description: PackageMetadata is the metadata for packages.
+ bytebase.v1.PaymentInfo:
+ type: object
+ properties:
+ totalPrice:
+ type: string
+ title: total_price
+ currency:
+ type: string
+ title: currency
+ periodStart:
+ type: string
+ title: period_start
+ periodEnd:
+ type: string
+ title: period_end
+ invoiceUrl:
+ type: string
+ title: invoice_url
+ description: Stripe Billing Portal URL for invoice management.
+ title: PaymentInfo
+ additionalProperties: false
bytebase.v1.PermissionDeniedDetail:
type: object
properties:
@@ -24162,6 +24332,81 @@ components:
title: value
title: LabelsEntry
additionalProperties: false
+ bytebase.v1.PurchaseBillingMethod:
+ type: object
+ properties:
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ discount:
+ title: discount
+ $ref: '#/components/schemas/bytebase.v1.PurchaseDiscount'
+ title: PurchaseBillingMethod
+ additionalProperties: false
+ bytebase.v1.PurchaseDiscount:
+ type: object
+ properties:
+ description:
+ type: string
+ title: description
+ promotionCode:
+ type: string
+ title: promotion_code
+ title: PurchaseDiscount
+ additionalProperties: false
+ bytebase.v1.PurchasePlan:
+ type: object
+ properties:
+ type:
+ title: type
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ selfServicePurchase:
+ type: boolean
+ title: self_service_purchase
+ additionals:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlanAdditional'
+ title: additionals
+ billingMethods:
+ type: array
+ items:
+ $ref: '#/components/schemas/bytebase.v1.PurchaseBillingMethod'
+ title: billing_methods
+ title: PurchasePlan
+ additionalProperties: false
+ bytebase.v1.PurchasePlanAdditional:
+ type: object
+ properties:
+ type:
+ title: type
+ $ref: '#/components/schemas/bytebase.v1.PurchasePlanAdditional.Type'
+ unitPrice:
+ type: integer
+ title: unit_price
+ format: int32
+ description: Price in USD cents per month.
+ freeCount:
+ type: integer
+ title: free_count
+ format: int32
+ minimumCount:
+ type: integer
+ title: minimum_count
+ format: int32
+ maximumCount:
+ type: integer
+ title: maximum_count
+ format: int32
+ description: -1 means unlimited.
+ title: PurchasePlanAdditional
+ additionalProperties: false
+ bytebase.v1.PurchasePlanAdditional.Type:
+ type: string
+ title: Type
+ enum:
+ - TYPE_UNSPECIFIED
+ - USER
bytebase.v1.QueryDataPolicy:
type: object
properties:
@@ -28227,6 +28472,35 @@ components:
required:
- project
additionalProperties: false
+ bytebase.v1.UpdatePurchaseRequest:
+ type: object
+ properties:
+ plan:
+ title: plan
+ $ref: '#/components/schemas/bytebase.v1.PlanType'
+ interval:
+ title: interval
+ $ref: '#/components/schemas/bytebase.v1.BillingInterval'
+ seats:
+ type: integer
+ title: seats
+ format: int32
+ etag:
+ type: string
+ title: etag
+ title: UpdatePurchaseRequest
+ additionalProperties: false
+ bytebase.v1.UpdatePurchaseResponse:
+ type: object
+ properties:
+ paymentUrl:
+ type: string
+ title: payment_url
+ description: |-
+ If set, redirect to this Stripe Checkout URL.
+ If empty, the update was applied directly using the existing payment method.
+ title: UpdatePurchaseResponse
+ additionalProperties: false
bytebase.v1.UpdateReleaseRequest:
type: object
properties:
@@ -30144,8 +30418,6 @@ components:
documentation for additional information.
security: []
tags:
- - name: SubscriptionService
- description: SubscriptionService manages enterprise subscriptions and licensing.
- name: AccessGrantService
description: AccessGrantService manages temporary access grants within projects.
- name: IssueService
@@ -30200,6 +30472,8 @@ tags:
description: ServiceAccountService manages service accounts for API integrations.
- name: SheetService
description: SheetService manages SQL scripts and saved queries.
+ - name: SubscriptionService
+ description: SubscriptionService manages enterprise subscriptions and licensing.
- name: WorkloadIdentityService
description: WorkloadIdentityService manages workload identities for external CI/CD integrations.
- name: WorksheetService
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 223beadd6a..4b0c4a2832 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -668,14 +668,30 @@
- [SheetService](#bytebase-v1-SheetService)
- [v1/subscription_service.proto](#v1_subscription_service-proto)
+ - [CancelPurchaseRequest](#bytebase-v1-CancelPurchaseRequest)
+ - [CancelPurchaseResponse](#bytebase-v1-CancelPurchaseResponse)
+ - [CreatePurchaseRequest](#bytebase-v1-CreatePurchaseRequest)
+ - [CreatePurchaseResponse](#bytebase-v1-CreatePurchaseResponse)
+ - [GetPaymentInfoRequest](#bytebase-v1-GetPaymentInfoRequest)
- [GetSubscriptionRequest](#bytebase-v1-GetSubscriptionRequest)
+ - [ListPurchasePlansRequest](#bytebase-v1-ListPurchasePlansRequest)
+ - [ListPurchasePlansResponse](#bytebase-v1-ListPurchasePlansResponse)
+ - [PaymentInfo](#bytebase-v1-PaymentInfo)
- [PlanConfig](#bytebase-v1-PlanConfig)
- [PlanLimitConfig](#bytebase-v1-PlanLimitConfig)
+ - [PurchaseBillingMethod](#bytebase-v1-PurchaseBillingMethod)
+ - [PurchaseDiscount](#bytebase-v1-PurchaseDiscount)
+ - [PurchasePlan](#bytebase-v1-PurchasePlan)
+ - [PurchasePlanAdditional](#bytebase-v1-PurchasePlanAdditional)
- [Subscription](#bytebase-v1-Subscription)
+ - [UpdatePurchaseRequest](#bytebase-v1-UpdatePurchaseRequest)
+ - [UpdatePurchaseResponse](#bytebase-v1-UpdatePurchaseResponse)
- [UpdateSubscriptionRequest](#bytebase-v1-UpdateSubscriptionRequest)
+ - [BillingInterval](#bytebase-v1-BillingInterval)
- [PlanFeature](#bytebase-v1-PlanFeature)
- [PlanType](#bytebase-v1-PlanType)
+ - [PurchasePlanAdditional.Type](#bytebase-v1-PurchasePlanAdditional-Type)
- [SubscriptionService](#bytebase-v1-SubscriptionService)
@@ -10806,6 +10822,68 @@ SheetService manages SQL scripts and saved queries.
+<a name="bytebase-v1-CancelPurchaseRequest"></a>
+
+### CancelPurchaseRequest
+
+
+
+
+
+
+
+<a name="bytebase-v1-CancelPurchaseResponse"></a>
+
+### CancelPurchaseResponse
+
+
+
+
+
+
+
+<a name="bytebase-v1-CreatePurchaseRequest"></a>
+
+### CreatePurchaseRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| plan | [PlanType](#bytebase-v1-PlanType) | | |
+| interval | [BillingInterval](#bytebase-v1-BillingInterval) | | |
+| seats | [int32](#int32) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-CreatePurchaseResponse"></a>
+
+### CreatePurchaseResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| payment_url | [string](#string) | | Stripe Checkout URL for the user to complete payment. |
+
+
+
+
+
+
+<a name="bytebase-v1-GetPaymentInfoRequest"></a>
+
+### GetPaymentInfoRequest
+
+
+
+
+
+
+
<a name="bytebase-v1-GetSubscriptionRequest"></a>
### GetSubscriptionRequest
@@ -10816,6 +10894,50 @@ SheetService manages SQL scripts and saved queries.
+<a name="bytebase-v1-ListPurchasePlansRequest"></a>
+
+### ListPurchasePlansRequest
+
+
+
+
+
+
+
+<a name="bytebase-v1-ListPurchasePlansResponse"></a>
+
+### ListPurchasePlansResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| plans | [PurchasePlan](#bytebase-v1-PurchasePlan) | repeated | |
+
+
+
+
+
+
+<a name="bytebase-v1-PaymentInfo"></a>
+
+### PaymentInfo
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| total_price | [string](#string) | | |
+| currency | [string](#string) | | |
+| period_start | [string](#string) | | |
+| period_end | [string](#string) | | |
+| invoice_url | [string](#string) | | Stripe Billing Portal URL for invoice management. |
+
+
+
+
+
+
<a name="bytebase-v1-PlanConfig"></a>
### PlanConfig
@@ -10850,6 +10972,75 @@ PlanLimitConfig represents a single plan&#39;s configuration
+<a name="bytebase-v1-PurchaseBillingMethod"></a>
+
+### PurchaseBillingMethod
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| interval | [BillingInterval](#bytebase-v1-BillingInterval) | | |
+| discount | [PurchaseDiscount](#bytebase-v1-PurchaseDiscount) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-PurchaseDiscount"></a>
+
+### PurchaseDiscount
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| description | [string](#string) | | |
+| promotion_code | [string](#string) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-PurchasePlan"></a>
+
+### PurchasePlan
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| type | [PlanType](#bytebase-v1-PlanType) | | |
+| self_service_purchase | [bool](#bool) | | |
+| additionals | [PurchasePlanAdditional](#bytebase-v1-PurchasePlanAdditional) | repeated | |
+| billing_methods | [PurchaseBillingMethod](#bytebase-v1-PurchaseBillingMethod) | repeated | |
+
+
+
+
+
+
+<a name="bytebase-v1-PurchasePlanAdditional"></a>
+
+### PurchasePlanAdditional
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| type | [PurchasePlanAdditional.Type](#bytebase-v1-PurchasePlanAdditional-Type) | | |
+| unit_price | [int32](#int32) | | Price in USD cents per month. |
+| free_count | [int32](#int32) | | |
+| minimum_count | [int32](#int32) | | |
+| maximum_count | [int32](#int32) | | -1 means unlimited. |
+
+
+
+
+
+
<a name="bytebase-v1-Subscription"></a>
### Subscription
@@ -10872,6 +11063,39 @@ PlanLimitConfig represents a single plan&#39;s configuration
+<a name="bytebase-v1-UpdatePurchaseRequest"></a>
+
+### UpdatePurchaseRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| plan | [PlanType](#bytebase-v1-PlanType) | | |
+| interval | [BillingInterval](#bytebase-v1-BillingInterval) | | |
+| seats | [int32](#int32) | | |
+| etag | [string](#string) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-UpdatePurchaseResponse"></a>
+
+### UpdatePurchaseResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| payment_url | [string](#string) | | If set, redirect to this Stripe Checkout URL. If empty, the update was applied directly using the existing payment method. |
+
+
+
+
+
+
<a name="bytebase-v1-UpdateSubscriptionRequest"></a>
### UpdateSubscriptionRequest
@@ -10890,6 +11114,19 @@ PlanLimitConfig represents a single plan&#39;s configuration
+<a name="bytebase-v1-BillingInterval"></a>
+
+### BillingInterval
+
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| BILLING_INTERVAL_UNSPECIFIED | 0 | |
+| MONTH | 1 | |
+| YEAR | 2 | |
+
+
+
<a name="bytebase-v1-PlanFeature"></a>
### PlanFeature
@@ -10985,6 +11222,18 @@ PlanFeature represents the available features in Bytebase
| ENTERPRISE | 3 | Enterprise plan with advanced features and dedicated support. |
+
+<a name="bytebase-v1-PurchasePlanAdditional-Type"></a>
+
+### PurchasePlanAdditional.Type
+
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| TYPE_UNSPECIFIED | 0 | |
+| USER | 1 | |
+
+
@@ -10998,7 +11247,12 @@ SubscriptionService manages enterprise subscriptions and licensing.
| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| GetSubscription | [GetSubscriptionRequest](#bytebase-v1-GetSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | GetSubscription returns the current subscription. If there is no license, we will return a free plan subscription without expiration time. If there is expired license, we will return a free plan subscription with the expiration time of the expired license. Permissions required: None |
-| UpdateSubscription | [UpdateSubscriptionRequest](#bytebase-v1-UpdateSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | Updates the enterprise license subscription. Permissions required: bb.settings.set |
+| UpdateSubscription | [UpdateSubscriptionRequest](#bytebase-v1-UpdateSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | Updates the enterprise license subscription (self-hosted only). Permissions required: bb.settings.set |
+| CreatePurchase | [CreatePurchaseRequest](#bytebase-v1-CreatePurchaseRequest) | [CreatePurchaseResponse](#bytebase-v1-CreatePurchaseResponse) | CreatePurchase creates a new subscription purchase (SaaS only). Returns a Stripe Checkout URL for the user to complete payment. |
+| UpdatePurchase | [UpdatePurchaseRequest](#bytebase-v1-UpdatePurchaseRequest) | [UpdatePurchaseResponse](#bytebase-v1-UpdatePurchaseResponse) | UpdatePurchase updates an existing subscription (SaaS only). May return a Stripe Checkout URL if payment method change is needed. |
+| CancelPurchase | [CancelPurchaseRequest](#bytebase-v1-CancelPurchaseRequest) | [CancelPurchaseResponse](#bytebase-v1-CancelPurchaseResponse) | CancelPurchase cancels an active subscription (SaaS only). |
+| GetPaymentInfo | [GetPaymentInfoRequest](#bytebase-v1-GetPaymentInfoRequest) | [PaymentInfo](#bytebase-v1-PaymentInfo) | GetPaymentInfo returns payment details for the current subscription (SaaS only). |
+| ListPurchasePlans | [ListPurchasePlansRequest](#bytebase-v1-ListPurchasePlansRequest) | [ListPurchasePlansResponse](#bytebase-v1-ListPurchasePlansResponse) | ListPurchasePlans returns available plans for self-service purchase. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 48f0b80d5e..4899d7f327 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -2724,10 +2724,42 @@
<a href="#v1%2fsubscription_service.proto">v1/subscription_service.proto</a>
<ul>
+ <li>
+ <a href="#bytebase.v1.CancelPurchaseRequest"><span class="badge">M</span>CancelPurchaseRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.CancelPurchaseResponse"><span class="badge">M</span>CancelPurchaseResponse</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.CreatePurchaseRequest"><span class="badge">M</span>CreatePurchaseRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.CreatePurchaseResponse"><span class="badge">M</span>CreatePurchaseResponse</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.GetPaymentInfoRequest"><span class="badge">M</span>GetPaymentInfoRequest</a>
+ </li>
+
<li>
<a href="#bytebase.v1.GetSubscriptionRequest"><span class="badge">M</span>GetSubscriptionRequest</a>
</li>
+ <li>
+ <a href="#bytebase.v1.ListPurchasePlansRequest"><span class="badge">M</span>ListPurchasePlansRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.ListPurchasePlansResponse"><span class="badge">M</span>ListPurchasePlansResponse</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.PaymentInfo"><span class="badge">M</span>PaymentInfo</a>
+ </li>
+
<li>
<a href="#bytebase.v1.PlanConfig"><span class="badge">M</span>PlanConfig</a>
</li>
@@ -2736,15 +2768,43 @@
<a href="#bytebase.v1.PlanLimitConfig"><span class="badge">M</span>PlanLimitConfig</a>
</li>
+ <li>
+ <a href="#bytebase.v1.PurchaseBillingMethod"><span class="badge">M</span>PurchaseBillingMethod</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.PurchaseDiscount"><span class="badge">M</span>PurchaseDiscount</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.PurchasePlan"><span class="badge">M</span>PurchasePlan</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.PurchasePlanAdditional"><span class="badge">M</span>PurchasePlanAdditional</a>
+ </li>
+
<li>
<a href="#bytebase.v1.Subscription"><span class="badge">M</span>Subscription</a>
</li>
+ <li>
+ <a href="#bytebase.v1.UpdatePurchaseRequest"><span class="badge">M</span>UpdatePurchaseRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.UpdatePurchaseResponse"><span class="badge">M</span>UpdatePurchaseResponse</a>
+ </li>
+
<li>
<a href="#bytebase.v1.UpdateSubscriptionRequest"><span class="badge">M</span>UpdateSubscriptionRequest</a>
</li>
+ <li>
+ <a href="#bytebase.v1.BillingInterval"><span class="badge">E</span>BillingInterval</a>
+ </li>
+
<li>
<a href="#bytebase.v1.PlanFeature"><span class="badge">E</span>PlanFeature</a>
</li>
@@ -2753,6 +2813,10 @@
<a href="#bytebase.v1.PlanType"><span class="badge">E</span>PlanType</a>
</li>
+ <li>
+ <a href="#bytebase.v1.PurchasePlanAdditional.Type"><span class="badge">E</span>PurchasePlanAdditional.Type</a>
+ </li>
+
<li>
@@ -30444,6 +30508,89 @@ Permissions required: bb.sheets.get</p></td>
<p></p>
+ <h3 id="bytebase.v1.CancelPurchaseRequest">CancelPurchaseRequest</h3>
+ <p></p>
+
+
+
+
+
+ <h3 id="bytebase.v1.CancelPurchaseResponse">CancelPurchaseResponse</h3>
+ <p></p>
+
+
+
+
+
+ <h3 id="bytebase.v1.CreatePurchaseRequest">CreatePurchaseRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>plan</td>
+ <td><a href="#bytebase.v1.PlanType">PlanType</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>interval</td>
+ <td><a href="#bytebase.v1.BillingInterval">BillingInterval</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>seats</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.CreatePurchaseResponse">CreatePurchaseResponse</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>payment_url</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Stripe Checkout URL for the user to complete payment. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.GetPaymentInfoRequest">GetPaymentInfoRequest</h3>
+ <p></p>
+
+
+
+
+
<h3 id="bytebase.v1.GetSubscriptionRequest">GetSubscriptionRequest</h3>
<p></p>
@@ -30451,6 +30598,89 @@ Permissions required: bb.sheets.get</p></td>
+ <h3 id="bytebase.v1.ListPurchasePlansRequest">ListPurchasePlansRequest</h3>
+ <p></p>
+
+
+
+
+
+ <h3 id="bytebase.v1.ListPurchasePlansResponse">ListPurchasePlansResponse</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>plans</td>
+ <td><a href="#bytebase.v1.PurchasePlan">PurchasePlan</a></td>
+ <td>repeated</td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.PaymentInfo">PaymentInfo</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>total_price</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>currency</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>period_start</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>period_end</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>invoice_url</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Stripe Billing Portal URL for invoice management. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.PlanConfig">PlanConfig</h3>
<p>PlanConfig represents the configuration for all plans loaded from plan.yaml</p>
@@ -30527,6 +30757,165 @@ Permissions required: bb.sheets.get</p></td>
+ <h3 id="bytebase.v1.PurchaseBillingMethod">PurchaseBillingMethod</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>interval</td>
+ <td><a href="#bytebase.v1.BillingInterval">BillingInterval</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>discount</td>
+ <td><a href="#bytebase.v1.PurchaseDiscount">PurchaseDiscount</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.PurchaseDiscount">PurchaseDiscount</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>description</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>promotion_code</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.PurchasePlan">PurchasePlan</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>type</td>
+ <td><a href="#bytebase.v1.PlanType">PlanType</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>self_service_purchase</td>
+ <td><a href="#bool">bool</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>additionals</td>
+ <td><a href="#bytebase.v1.PurchasePlanAdditional">PurchasePlanAdditional</a></td>
+ <td>repeated</td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>billing_methods</td>
+ <td><a href="#bytebase.v1.PurchaseBillingMethod">PurchaseBillingMethod</a></td>
+ <td>repeated</td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.PurchasePlanAdditional">PurchasePlanAdditional</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>type</td>
+ <td><a href="#bytebase.v1.PurchasePlanAdditional.Type">PurchasePlanAdditional.Type</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>unit_price</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p>Price in USD cents per month. </p></td>
+ </tr>
+
+ <tr>
+ <td>free_count</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>minimum_count</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>maximum_count</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p>-1 means unlimited. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.Subscription">Subscription</h3>
<p></p>
@@ -30600,6 +30989,76 @@ Permissions required: bb.sheets.get</p></td>
+ <h3 id="bytebase.v1.UpdatePurchaseRequest">UpdatePurchaseRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>plan</td>
+ <td><a href="#bytebase.v1.PlanType">PlanType</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>interval</td>
+ <td><a href="#bytebase.v1.BillingInterval">BillingInterval</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>seats</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>etag</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.UpdatePurchaseResponse">UpdatePurchaseResponse</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>payment_url</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>If set, redirect to this Stripe Checkout URL.
+If empty, the update was applied directly using the existing payment method. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.UpdateSubscriptionRequest">UpdateSubscriptionRequest</h3>
<p></p>
@@ -30634,6 +31093,35 @@ In this situation, `update_mask` is ignored. </p></td>
+ <h3 id="bytebase.v1.BillingInterval">BillingInterval</h3>
+ <p></p>
+ <table class="enum-table">
+ <thead>
+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>BILLING_INTERVAL_UNSPECIFIED</td>
+ <td>0</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>MONTH</td>
+ <td>1</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>YEAR</td>
+ <td>2</td>
+ <td><p></p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
<h3 id="bytebase.v1.PlanFeature">PlanFeature</h3>
<p>PlanFeature represents the available features in Bytebase</p>
<table class="enum-table">
@@ -31112,6 +31600,29 @@ In this situation, `update_mask` is ignored. </p></td>
</tbody>
</table>
+ <h3 id="bytebase.v1.PurchasePlanAdditional.Type">PurchasePlanAdditional.Type</h3>
+ <p></p>
+ <table class="enum-table">
+ <thead>
+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>TYPE_UNSPECIFIED</td>
+ <td>0</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>USER</td>
+ <td>1</td>
+ <td><p></p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
@@ -31138,10 +31649,47 @@ Permissions required: None</p></td>
<td>UpdateSubscription</td>
<td><a href="#bytebase.v1.UpdateSubscriptionRequest">UpdateSubscriptionRequest</a></td>
<td><a href="#bytebase.v1.Subscription">Subscription</a></td>
- <td><p>Updates the enterprise license subscription.
+ <td><p>Updates the enterprise license subscription (self-hosted only).
Permissions required: bb.settings.set</p></td>
</tr>
+ <tr>
+ <td>CreatePurchase</td>
+ <td><a href="#bytebase.v1.CreatePurchaseRequest">CreatePurchaseRequest</a></td>
+ <td><a href="#bytebase.v1.CreatePurchaseResponse">CreatePurchaseResponse</a></td>
+ <td><p>CreatePurchase creates a new subscription purchase (SaaS only).
+Returns a Stripe Checkout URL for the user to complete payment.</p></td>
+ </tr>
+
+ <tr>
+ <td>UpdatePurchase</td>
+ <td><a href="#bytebase.v1.UpdatePurchaseRequest">UpdatePurchaseRequest</a></td>
+ <td><a href="#bytebase.v1.UpdatePurchaseResponse">UpdatePurchaseResponse</a></td>
+ <td><p>UpdatePurchase updates an existing subscription (SaaS only).
+May return a Stripe Checkout URL if payment method change is needed.</p></td>
+ </tr>
+
+ <tr>
+ <td>CancelPurchase</td>
+ <td><a href="#bytebase.v1.CancelPurchaseRequest">CancelPurchaseRequest</a></td>
+ <td><a href="#bytebase.v1.CancelPurchaseResponse">CancelPurchaseResponse</a></td>
+ <td><p>CancelPurchase cancels an active subscription (SaaS only).</p></td>
+ </tr>
+
+ <tr>
+ <td>GetPaymentInfo</td>
+ <td><a href="#bytebase.v1.GetPaymentInfoRequest">GetPaymentInfoRequest</a></td>
+ <td><a href="#bytebase.v1.PaymentInfo">PaymentInfo</a></td>
+ <td><p>GetPaymentInfo returns payment details for the current subscription (SaaS only).</p></td>
+ </tr>
+
+ <tr>
+ <td>ListPurchasePlans</td>
+ <td><a href="#bytebase.v1.ListPurchasePlansRequest">ListPurchasePlansRequest</a></td>
+ <td><a href="#bytebase.v1.ListPurchasePlansResponse">ListPurchasePlansResponse</a></td>
+ <td><p>ListPurchasePlans returns available plans for self-service purchase.</p></td>
+ </tr>
+
</tbody>
</table>
@@ -31180,6 +31728,56 @@ Permissions required: bb.settings.set</p></td>
</tr>
+
+
+ <tr>
+ <td>CreatePurchase</td>
+ <td>POST</td>
+ <td>/v1/subscription:purchase</td>
+ <td>*</td>
+ </tr>
+
+
+
+
+ <tr>
+ <td>UpdatePurchase</td>
+ <td>POST</td>
+ <td>/v1/subscription:updatePurchase</td>
+ <td>*</td>
+ </tr>
+
+
+
+
+ <tr>
+ <td>CancelPurchase</td>
+ <td>POST</td>
+ <td>/v1/subscription:cancelPurchase</td>
+ <td>*</td>
+ </tr>
+
+
+
+
+ <tr>
+ <td>GetPaymentInfo</td>
+ <td>GET</td>
+ <td>/v1/subscription/paymentInfo</td>
+ <td></td>
+ </tr>
+
+
+
+
+ <tr>
+ <td>ListPurchasePlans</td>
+ <td>GET</td>
+ <td>/v1/subscription/plans</td>
+ <td></td>
+ </tr>
+
+
</tbody>
</table>
diff --git a/proto/v1/v1/subscription_service.proto b/proto/v1/v1/subscription_service.proto
index dc1237230a..f04e2e1a40 100644
--- a/proto/v1/v1/subscription_service.proto
+++ b/proto/v1/v1/subscription_service.proto
@@ -22,7 +22,7 @@ service SubscriptionService {
option (bytebase.v1.allow_without_credential) = true;
}
- // Updates the enterprise license subscription.
+ // Updates the enterprise license subscription (self-hosted only).
// Permissions required: bb.settings.set
rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
option (google.api.http) = {
@@ -33,6 +33,51 @@ service SubscriptionService {
option (bytebase.v1.permission) = "bb.settings.set";
option (bytebase.v1.auth_method) = IAM;
}
+
+ // CreatePurchase creates a new subscription purchase (SaaS only).
+ // Returns a Stripe Checkout URL for the user to complete payment.
+ rpc CreatePurchase(CreatePurchaseRequest) returns (CreatePurchaseResponse) {
+ option (google.api.http) = {
+ post: "/v1/subscription:purchase"
+ body: "*"
+ };
+ option (bytebase.v1.permission) = "bb.subscription.manage";
+ option (bytebase.v1.auth_method) = IAM;
+ }
+
+ // UpdatePurchase updates an existing subscription (SaaS only).
+ // May return a Stripe Checkout URL if payment method change is needed.
+ rpc UpdatePurchase(UpdatePurchaseRequest) returns (UpdatePurchaseResponse) {
+ option (google.api.http) = {
+ post: "/v1/subscription:updatePurchase"
+ body: "*"
+ };
+ option (bytebase.v1.permission) = "bb.subscription.manage";
+ option (bytebase.v1.auth_method) = IAM;
+ }
+
+ // CancelPurchase cancels an active subscription (SaaS only).
+ rpc CancelPurchase(CancelPurchaseRequest) returns (CancelPurchaseResponse) {
+ option (google.api.http) = {
+ post: "/v1/subscription:cancelPurchase"
+ body: "*"
+ };
+ option (bytebase.v1.permission) = "bb.subscription.manage";
+ option (bytebase.v1.auth_method) = IAM;
+ }
+
+ // GetPaymentInfo returns payment details for the current subscription (SaaS only).
+ rpc GetPaymentInfo(GetPaymentInfoRequest) returns (PaymentInfo) {
+ option (google.api.http) = {get: "/v1/subscription/paymentInfo"};
+ option (bytebase.v1.permission) = "bb.subscription.manage";
+ option (bytebase.v1.auth_method) = IAM;
+ }
+
+ // ListPurchasePlans returns available plans for self-service purchase.
+ rpc ListPurchasePlans(ListPurchasePlansRequest) returns (ListPurchasePlansResponse) {
+ option (google.api.http) = {get: "/v1/subscription/plans"};
+ option (bytebase.v1.allow_without_credential) = true;
+ }
}
message GetSubscriptionRequest {}
@@ -45,6 +90,92 @@ message UpdateSubscriptionRequest {
bool allow_missing = 2;
}
+// Purchase messages
+
+message CreatePurchaseRequest {
+ PlanType plan = 1;
+ BillingInterval interval = 2;
+ int32 seats = 3;
+}
+
+message CreatePurchaseResponse {
+ // Stripe Checkout URL for the user to complete payment.
+ string payment_url = 1;
+}
+
+message UpdatePurchaseRequest {
+ PlanType plan = 1;
+ BillingInterval interval = 2;
+ int32 seats = 3;
+ string etag = 4;
+}
+
+message UpdatePurchaseResponse {
+ // If set, redirect to this Stripe Checkout URL.
+ // If empty, the update was applied directly using the existing payment method.
+ string payment_url = 1;
+}
+
+message CancelPurchaseRequest {}
+
+message CancelPurchaseResponse {}
+
+message GetPaymentInfoRequest {}
+
+message PaymentInfo {
+ string total_price = 1;
+ string currency = 2;
+ string period_start = 3;
+ string period_end = 4;
+ // Stripe Billing Portal URL for invoice management.
+ string invoice_url = 5;
+}
+
+enum BillingInterval {
+ BILLING_INTERVAL_UNSPECIFIED = 0;
+ MONTH = 1;
+ YEAR = 2;
+}
+
+message PurchasePlan {
+ PlanType type = 1;
+ bool self_service_purchase = 2;
+ repeated PurchasePlanAdditional additionals = 3;
+ repeated PurchaseBillingMethod billing_methods = 4;
+}
+
+message PurchasePlanAdditional {
+ enum Type {
+ TYPE_UNSPECIFIED = 0;
+ USER = 1;
+ }
+ Type type = 1;
+ // Price in USD cents per month.
+ int32 unit_price = 2;
+ int32 free_count = 3;
+ int32 minimum_count = 4;
+ // -1 means unlimited.
+ int32 maximum_count = 5;
+}
+
+message PurchaseBillingMethod {
+ BillingInterval interval = 1;
+ PurchaseDiscount discount = 2;
+}
+
+message PurchaseDiscount {
+ string description = 1;
+ string promotion_code = 2;
+}
+
+message ListPurchasePlansRequest {}
+
+message ListPurchasePlansResponse {
+ repeated PurchasePlan plans = 1;
+}
+
+// Existing types
+
enum PlanType {
// Unspecified plan type.
PLAN_TYPE_UNSPECIFIED = 0;