feat(billing): move plan writes to AdminService and add ListAllPlans - #1830
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesPlan lifecycle management
Proto dependency update
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cc87a8e to
32085ea
Compare
Coverage Report for CI Build 31151483622Coverage increased (+0.2%) to 47.945%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
32085ea to
0abead7
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 36ed8dac-defb-4d0b-89e4-deba6b82920a
⛔ Files ignored due to path filters (4)
proto/v1beta1/admin.pb.gois excluded by!**/*.pb.go,!proto/**proto/v1beta1/frontier.pb.gois excluded by!**/*.pb.go,!proto/**proto/v1beta1/frontierv1beta1connect/admin.connect.gois excluded by!proto/**proto/v1beta1/frontierv1beta1connect/frontier.connect.gois excluded by!proto/**
📒 Files selected for processing (19)
Makefilebilling/checkout/checkout.gobilling/checkout/service.gobilling/plan/plan.gobilling/plan/plan_test.gobilling/plan/service.gobilling/subscription/service.gobilling/subscription/service_test.gobilling/subscription/subscription.gointernal/api/v1beta1connect/billing_checkout.gointernal/api/v1beta1connect/billing_plan.gointernal/api/v1beta1connect/billing_plan_test.gointernal/api/v1beta1connect/billing_subscription.gointernal/api/v1beta1connect/errors.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/plan_service.gointernal/store/postgres/billing_plan_repository.gopkg/server/connect_interceptors/authorization.gotest/e2e/regression/billing_test.go
|
A few findings from a review pass, most severe first:
|
0d9441a to
b5228df
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…, block changes onto them
… the ListAllPlans filter contract
…ss explicit state
6957698 to
35004d5
Compare
What
Wire the frontier side of the plan admin APIs from raystack/proton#496.
CreatePlanandUpdatePlantoAdminService(super user only). They were onFrontierServicebefore.ListAllPlansonAdminService. It lists every plan, including disabled ones. An empty state returns all plans; a set state filters to it.UpdatePlanis implemented (it returnedUnimplementedbefore) and takes a dedicatedUpdatePlanRequestBody(title, description, on_start_credits, trial_days, state, metadata). It is a full replacement of those fields. It does not touch interval, products, or name. Products are managed throughCreatePlan's upsert.CreatePlancarries the planstate.ListPlansandGetPlanstay onFrontierService, unchanged.ListPlansreturns active plans only.stateis required on the write APIs (activeordisabled), so a plan can never be stored with an empty state.How
ConnectHandlerserves both services, so the existingCreatePlanmethod now satisfiesAdminService.UpdatePlanandListAllPlansare added to it.AdminServiceplan RPCs behindIsSuperUser, and the oldFrontierServiceplan entries are removed. Any endpoint not listed is denied by default, so these entries are required.ListAllPlanspasses aplan.StateAllsentinel to the repository so an empty state lists plans in every state.ListPlansstill defaults to active only.Review fixes (from an independent review)
intervalthat the handler ignored.activeon update, so an update can no longer silently reactivate a disabled plan.UpdatePlanRequest.bodyis required.UpdatePlanmaps a missing plan toNotFoundand an invalid id/name toInvalidArgumentinstead of an opaque 500.activeon create, so the create and seed paths can never store an empty state.Depends on
Related fixes
ListPlans/ListAllPlansreported each product's title as itsbehavior(a copy-paste bug from the plan-list query in feat: reduce DB calls in plan list API #782). Now reads thebehaviorcolumn. No functional impact: all billing logic fetches products viaGetByID/productService, which read behavior correctly; only the two list responses were wrong. The frontend does not read the field.ListAllPlansomitting product-less plans) was fixed separately in fix(billing): include plans without products in plan listings #1834, now merged to main.Testing
UpdatePlanandListAllPlanshandlers.ListAllPlansvsListPlansvisibility of a disabled plan.