Skip to content

feat(api): add settlement mode to v1 api handlers - #4044

Merged
tothandras merged 5 commits into
mainfrom
feat/add-settlement-mode-to-v1-api-handlers
Apr 1, 2026
Merged

tothandras merged 5 commits into
mainfrom
feat/add-settlement-mode-to-v1-api-handlers

Conversation

@mark-vass-konghq

@mark-vass-konghq mark-vass-konghq commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Adds settlement mode to subscription and plan handlers, mapping.

Summary by CodeRabbit

  • New Features

    • Added credit configuration with an enable/disable flag and CLI/env defaults.
    • API, handlers and router now accept and propagate the credit configuration; settlement mode is exposed in plan and subscription payloads.
    • Request validation blocks create/change when using credit-only settlement mode and credits are disabled.
  • Tests

    • Added unit and end-to-end tests verifying credit gating for plan and subscription create/change flows.

@mark-vass-konghq mark-vass-konghq self-assigned this Mar 31, 2026
@mark-vass-konghq
mark-vass-konghq requested a review from a team as a code owner March 31, 2026 12:23
@mark-vass-konghq mark-vass-konghq added release-note/feature Release note: Exciting New Features area/billing labels Mar 31, 2026
@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a CreditConfiguration flag to app config, wires it through DI and the router, and threads it into plan and subscription handlers which now reject requests using settlementMode "credit_only" when credits are disabled; mappings, plan equality, and tests updated accordingly.

Changes

Cohort / File(s) Summary
App config & wiring
app/common/config.go, app/config/config.go, app/config/credit.go, app/config/config_test.go
Introduce CreditConfiguration with Enabled flag, Viper defaults and --credit-enabled flag, validate it in Configuration.Validate(), and expose it via the exported Wire Config set; update test expectations.
Plan surface & mapping
openmeter/productcatalog/plan.go, openmeter/productcatalog/plan/httpdriver/plan.go, openmeter/productcatalog/plan/httpdriver/mapping.go, openmeter/productcatalog/plan/httpdriver/credit_test.go
Include SettlementMode in PlanMeta.Equal and API mappings; change CreatePlan handler to accept CreditConfiguration and reject credit_only when disabled; add handler tests.
Subscription handlers & mapping
openmeter/productcatalog/subscription/http/handler.go, openmeter/productcatalog/subscription/http/create.go, openmeter/productcatalog/subscription/http/change.go, openmeter/productcatalog/subscription/http/mapping.go, openmeter/productcatalog/subscription/http/credit_test.go
Add Credit to handler config, switch handlers to HandlerWithArgs to receive CreditConfiguration, and validate/reject credit_only in custom-plan flows; expose settlement mode in mappings; add tests.
Router & server wiring
cmd/server/main.go, openmeter/server/router/router.go, openmeter/server/router/plan.go, openmeter/server/router/subscription.go
Add Credit to router Config and pass a.config.Credit into plan and subscription handlers so they receive runtime credit config.
E2E tests
e2e/productcatalog_test.go
Add end-to-end tests asserting credit_only is rejected when credits are disabled and accepted when enabled for plan creation and custom subscription create/change flows.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant Router as Router (HTTP)
participant Handler as Plan/Subscription Handler
participant Config as CreditConfiguration
participant Service as Domain Service
Client->>Router: POST create/change (settlementMode: credit_only)
Router->>Handler: Handler.With(Config) -> ServeHTTP
Handler->>Config: read Enabled flag
alt Config.Enabled == false and settlementMode == credit_only
Handler-->>Client: 400 Bad Request (credits not enabled)
else
Handler->>Service: validate and create/update plan/subscription
Service-->>Handler: success
Handler-->>Client: 201/200 Created/OK
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

area/product-catalog, area/subscriptions

Suggested reviewers

  • tothandras
  • GAlexIHU
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(api): add settlement mode to v1 api handlers' accurately summarizes the main change: adding settlement mode support to API handlers with proper mapping and configuration gating.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-settlement-mode-to-v1-api-handlers

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
app/config/config.go (1)

37-37: Consider adding Credit.Validate() to the Validate() method.

I noticed that Configuration.Validate() calls c.Customer.Validate() (line 163-165) but doesn't call c.Credit.Validate(). While the current CreditConfiguration.Validate() is a no-op, adding the call maintains consistency and future-proofs the code if validation logic is added later.

♻️ Suggested addition

Add this somewhere in the Validate() method (e.g., after the Customer validation block):

if err := c.Credit.Validate(); err != nil {
    errs = append(errs, errorsx.WithPrefix(err, "credit"))
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/config/config.go` at line 37, Configuration.Validate currently calls
c.Customer.Validate() but omits c.Credit.Validate(), which risks missing future
credit validation; update the Validate method (Configuration.Validate) to call
c.Credit.Validate() and, on error, append it to errs using
errorsx.WithPrefix(err, "credit") (mirroring the existing pattern used for
c.Customer.Validate()) so credit validation is consistently handled.
openmeter/productcatalog/plan/httpdriver/credit_test.go (1)

109-113: Nice test coverage — one extra assertion would make it even tighter.

Could we also assert whether CreatePlan was called? That would explicitly prove the disabled path short-circuits before hitting the service.

💡 Suggested tweak
  for _, tt := range tests {
  	t.Run(tt.name, func(t *testing.T) {
+ 		createPlanCalled := false
  		svc := &stubPlanService{
  			createPlan: func(_ context.Context, params plan.CreatePlanInput) (*plan.Plan, error) {
+ 				createPlanCalled = true
  				return stubPlan(namespace, params.SettlementMode), nil
  			},
  		}
@@
  		require.Equal(t, tt.wantStatusCode, rec.Code, "response body: %s", rec.Body.String())
  		if !tt.creditEnabled {
  			assert.Contains(t, rec.Body.String(), "credits are not enabled on this deployment of OpenMeter")
+ 			assert.False(t, createPlanCalled, "service should not be called when credit is disabled")
+ 		} else {
+ 			assert.True(t, createPlanCalled, "service should be called when credit is enabled")
  		}
  	})
  }

As per coding guidelines "**/*_test.go: Make sure the tests are comprehensive and cover the changes."

Also applies to: 125-131

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openmeter/productcatalog/plan/httpdriver/credit_test.go` around lines 109 -
113, Add an assertion that the stubbed service's CreatePlan path was invoked (or
not) to prove the disabled path short-circuits: modify the stubPlanService used
in credit_test.go to record calls to the createPlan function (e.g., increment a
counter or set a boolean when createPlan is executed) and then assert on that
counter/flag after the request—for the disabled-case test assert it remained
zero/false, and for the enabled-case test assert it was called once/true; update
both occurrences that construct stubPlanService (the createPlan closures around
the current stubPlan(namespace, params.SettlementMode) returns, including the
similar block at the other test region) to include this call-tracking and
corresponding assertions.
openmeter/productcatalog/plan/httpdriver/plan.go (1)

126-126: Optional: centralize the repeated “credits are not enabled…” error message.

Tiny maintainability nit — this literal now appears in multiple handlers (openmeter/productcatalog/plan/httpdriver/plan.go, openmeter/productcatalog/subscription/http/create.go, openmeter/productcatalog/subscription/http/change.go). A shared constant/helper would avoid drift later.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openmeter/productcatalog/plan/httpdriver/plan.go` at line 126, The repeated
literal "credits are not enabled on this deployment of OpenMeter" should be
centralized: add a single exported constant (e.g. CreditsNotEnabledMsg) or a
small helper function (e.g. NewCreditsNotEnabledError() that returns
models.NewGenericValidationError(fmt.Errorf(CreditsNotEnabledMsg))) in a shared
package (productcatalog or a new errors package), then replace the inline string
in plan.go (where CreatePlanRequest error is created via
models.NewGenericValidationError), subscription/http/create.go and
subscription/http/change.go with the new constant/helper so all three locations
reference the same source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openmeter/productcatalog/subscription/http/credit_test.go`:
- Around line 199-211: Remove the redundant Credit configuration from the
handler construction: in the NewHandler call that builds a
httpdriver.HandlerConfig, drop the Credit:
appconfig.CreditConfiguration{Enabled: tt.creditEnabled} field and rely solely
on CreateSubscription().With(appconfig.CreditConfiguration{Enabled:
tt.creditEnabled}) to supply the credit config at request time; this keeps
NewHandler/HandlerConfig and the CreateSubscription().With(...) usage consistent
and avoids duplicate config application.

---

Nitpick comments:
In `@app/config/config.go`:
- Line 37: Configuration.Validate currently calls c.Customer.Validate() but
omits c.Credit.Validate(), which risks missing future credit validation; update
the Validate method (Configuration.Validate) to call c.Credit.Validate() and, on
error, append it to errs using errorsx.WithPrefix(err, "credit") (mirroring the
existing pattern used for c.Customer.Validate()) so credit validation is
consistently handled.

In `@openmeter/productcatalog/plan/httpdriver/credit_test.go`:
- Around line 109-113: Add an assertion that the stubbed service's CreatePlan
path was invoked (or not) to prove the disabled path short-circuits: modify the
stubPlanService used in credit_test.go to record calls to the createPlan
function (e.g., increment a counter or set a boolean when createPlan is
executed) and then assert on that counter/flag after the request—for the
disabled-case test assert it remained zero/false, and for the enabled-case test
assert it was called once/true; update both occurrences that construct
stubPlanService (the createPlan closures around the current stubPlan(namespace,
params.SettlementMode) returns, including the similar block at the other test
region) to include this call-tracking and corresponding assertions.

In `@openmeter/productcatalog/plan/httpdriver/plan.go`:
- Line 126: The repeated literal "credits are not enabled on this deployment of
OpenMeter" should be centralized: add a single exported constant (e.g.
CreditsNotEnabledMsg) or a small helper function (e.g.
NewCreditsNotEnabledError() that returns
models.NewGenericValidationError(fmt.Errorf(CreditsNotEnabledMsg))) in a shared
package (productcatalog or a new errors package), then replace the inline string
in plan.go (where CreatePlanRequest error is created via
models.NewGenericValidationError), subscription/http/create.go and
subscription/http/change.go with the new constant/helper so all three locations
reference the same source of truth.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ca56412-aab0-414a-bfe2-a102701b482f

📥 Commits

Reviewing files that changed from the base of the PR and between b5c96e1 and ffb5089.

📒 Files selected for processing (17)
  • app/common/config.go
  • app/config/config.go
  • app/config/config_test.go
  • app/config/credit.go
  • cmd/server/main.go
  • openmeter/productcatalog/plan.go
  • openmeter/productcatalog/plan/httpdriver/credit_test.go
  • openmeter/productcatalog/plan/httpdriver/mapping.go
  • openmeter/productcatalog/plan/httpdriver/plan.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/subscription/http/credit_test.go
  • openmeter/productcatalog/subscription/http/handler.go
  • openmeter/productcatalog/subscription/http/mapping.go
  • openmeter/server/router/plan.go
  • openmeter/server/router/router.go
  • openmeter/server/router/subscription.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
openmeter/productcatalog/plan/httpdriver/credit_test.go (1)

77-85: Add one more case to prove the guard is credit_only-specific.

Right now both rows send credit_only. A third case (creditEnabled=false + non-credit settlement mode) would guard against accidentally rejecting all settlement modes when credits are off.

Suggested test extension
 const planCreateCreditOnlyBody = `{
   "key": "test-plan",
   "name": "Test Plan",
   "currency": "USD",
   "billingCadence": "P1M",
   "settlementMode": "credit_only",
   "phases": [{"key": "default", "name": "Default Phase", "rateCards": []}]
 }`
+
+const planCreateInArrearsBody = `{
+  "key": "test-plan",
+  "name": "Test Plan",
+  "currency": "USD",
+  "billingCadence": "P1M",
+  "settlementMode": "in_arrears",
+  "phases": [{"key": "default", "name": "Default Phase", "rateCards": []}]
+}`

 tests := []struct {
   name           string
   creditEnabled  bool
+  body           string
   wantStatusCode int
 }{
   {
     name:           "credit disabled: credit_only settlement mode is rejected",
     creditEnabled:  false,
+    body:           planCreateCreditOnlyBody,
     wantStatusCode: http.StatusBadRequest,
   },
   {
     name:           "credit enabled: credit_only settlement mode is allowed",
     creditEnabled:  true,
+    body:           planCreateCreditOnlyBody,
     wantStatusCode: http.StatusCreated,
   },
+  {
+    name:           "credit disabled: in_arrears settlement mode is allowed",
+    creditEnabled:  false,
+    body:           planCreateInArrearsBody,
+    wantStatusCode: http.StatusCreated,
+  },
 }
 ...
-req := httptest.NewRequest(http.MethodPost, "/api/v1/plans", bytes.NewBufferString(planCreateCreditOnlyBody))
+req := httptest.NewRequest(http.MethodPost, "/api/v1/plans", bytes.NewBufferString(tt.body))

As per coding guidelines, **/*_test.go: "Make sure the tests are comprehensive and cover the changes."

Also applies to: 90-105, 127-135

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openmeter/productcatalog/plan/httpdriver/credit_test.go` around lines 77 -
85, Add a third test case that proves the guard is specific to "credit_only":
when creditEnabled=false but the plan's settlementMode is a non-credit value
(e.g., "invoice" or "cash"), the request should not be rejected. Create a new
JSON test payload (e.g., planCreateNonCreditBody) with settlementMode set to a
non-credit string and use it in the same test table/rows where
planCreateCreditOnlyBody is used, asserting the expected success/accept
behavior; mirror this addition in the other related test blocks referenced (the
assertions around the ranges that start at lines ~90-105 and ~127-135) so all
cases cover creditEnabled=true/false × settlementMode credit_only/non-credit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@openmeter/productcatalog/plan/httpdriver/credit_test.go`:
- Around line 77-85: Add a third test case that proves the guard is specific to
"credit_only": when creditEnabled=false but the plan's settlementMode is a
non-credit value (e.g., "invoice" or "cash"), the request should not be
rejected. Create a new JSON test payload (e.g., planCreateNonCreditBody) with
settlementMode set to a non-credit string and use it in the same test table/rows
where planCreateCreditOnlyBody is used, asserting the expected success/accept
behavior; mirror this addition in the other related test blocks referenced (the
assertions around the ranges that start at lines ~90-105 and ~127-135) so all
cases cover creditEnabled=true/false × settlementMode credit_only/non-credit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4d9a7ba-c7ed-49aa-b99a-d3c7f35e1f21

📥 Commits

Reviewing files that changed from the base of the PR and between 28477dd and c46bb08.

📒 Files selected for processing (4)
  • app/config/config.go
  • app/config/credit.go
  • openmeter/productcatalog/plan/httpdriver/credit_test.go
  • openmeter/productcatalog/subscription/http/credit_test.go
✅ Files skipped from review due to trivial changes (2)
  • app/config/credit.go
  • openmeter/productcatalog/subscription/http/credit_test.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
e2e/productcatalog_test.go (1)

1200-1211: Consider validating the error message content.

The test correctly checks for HTTP 400, but verifying the error message would ensure the right validation triggered (not some other 400 error). This would make the test more robust against future changes.

💡 Optional: Assert error message content
 		res, err := client.CreatePlanWithResponse(ctx, api.PlanCreate{
 			Key:            "test_plan_settlement_credit_only",
 			Name:           "Credit Only Plan",
 			Currency:       "USD",
 			BillingCadence: "P1M",
 			SettlementMode: lo.ToPtr(api.BillingSettlementModeCreditOnly),
 			Phases:         []api.PlanPhase{defaultPhase},
 		})
 		require.Nil(t, err)
 		assert.Equal(t, 400, res.StatusCode(), "received the following body: %s", res.Body)
+		require.NotNil(t, res.ApplicationproblemJSON400)
+		assert.Contains(t, res.ApplicationproblemJSON400.Detail, "credits are not enabled")
 	})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e/productcatalog_test.go` around lines 1200 - 1211, Enhance the "Should
reject a plan with credit_only settlement mode when credit is disabled" test by
asserting the returned error message/validation in the response body from
client.CreatePlanWithResponse (res) in addition to the 400 status; locate the
test that builds api.PlanCreate and after require.Nil(t, err) and
assert.Equal(t, 400, res.StatusCode()) parse res.Body or use the response helper
to extract the error payload and assert it contains the expected validation text
(e.g., a message or code indicating credits are disabled or settlement mode is
invalid) so the test ensures the specific validation triggered rather than any
generic 400.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@e2e/productcatalog_test.go`:
- Around line 1200-1211: Enhance the "Should reject a plan with credit_only
settlement mode when credit is disabled" test by asserting the returned error
message/validation in the response body from client.CreatePlanWithResponse (res)
in addition to the 400 status; locate the test that builds api.PlanCreate and
after require.Nil(t, err) and assert.Equal(t, 400, res.StatusCode()) parse
res.Body or use the response helper to extract the error payload and assert it
contains the expected validation text (e.g., a message or code indicating
credits are disabled or settlement mode is invalid) so the test ensures the
specific validation triggered rather than any generic 400.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 65a6feb9-7fb9-486d-bdd0-036b9103ab83

📥 Commits

Reviewing files that changed from the base of the PR and between c46bb08 and 9d6aebd.

📒 Files selected for processing (1)
  • e2e/productcatalog_test.go

@mark-vass-konghq
mark-vass-konghq force-pushed the feat/add-settlement-mode-to-v1-api-handlers branch from 9d6aebd to 07d9844 Compare March 31, 2026 13:12
@mark-vass-konghq
mark-vass-konghq force-pushed the feat/add-settlement-mode-to-v1-api-handlers branch from 07d9844 to 303f180 Compare March 31, 2026 13:12
@mark-vass-konghq
mark-vass-konghq force-pushed the feat/add-settlement-mode-to-v1-api-handlers branch from 303f180 to eb3e295 Compare March 31, 2026 13:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openmeter/productcatalog/plan.go`:
- Around line 298-300: The new SettlementMode comparison in Plan equality
requires that the update-noop guard in UpdatePlanInput.Equal also compare
settlement mode; update the UpdatePlanInput.Equal(...) method (in
openmeter/productcatalog/plan/service.go) to include a check that the incoming
UpdatePlanInput.SettlementMode equals the existing Plan.SettlementMode (handling
any pointer/zero-value semantic your codebase uses), so a settlement-mode-only
change is no longer treated as unchanged and skipped.

In `@openmeter/productcatalog/subscription/http/mapping.go`:
- Line 470: When mapping a.SettlementMode in mapping.go, ensure you default
missing/ nil values to the documented default before converting to the domain
type: replace the direct
productcatalog.SettlementMode(lo.FromPtr(a.SettlementMode)) usage with logic
that reads the pointer (lo.FromPtr or equivalent), and if the result is
empty/zero, substitute the default "credit_then_invoice" (or the corresponding
constant) and then construct productcatalog.SettlementMode from that value so
you never store an empty settlement mode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6b0efec-0545-48e6-9da1-487e9dcc2606

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6aebd and 303f180.

📒 Files selected for processing (18)
  • app/common/config.go
  • app/config/config.go
  • app/config/config_test.go
  • app/config/credit.go
  • cmd/server/main.go
  • e2e/productcatalog_test.go
  • openmeter/productcatalog/plan.go
  • openmeter/productcatalog/plan/httpdriver/credit_test.go
  • openmeter/productcatalog/plan/httpdriver/mapping.go
  • openmeter/productcatalog/plan/httpdriver/plan.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/subscription/http/credit_test.go
  • openmeter/productcatalog/subscription/http/handler.go
  • openmeter/productcatalog/subscription/http/mapping.go
  • openmeter/server/router/plan.go
  • openmeter/server/router/router.go
  • openmeter/server/router/subscription.go
✅ Files skipped from review due to trivial changes (5)
  • openmeter/server/router/plan.go
  • openmeter/productcatalog/subscription/http/handler.go
  • app/config/credit.go
  • openmeter/productcatalog/plan/httpdriver/credit_test.go
  • openmeter/productcatalog/subscription/http/credit_test.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • openmeter/server/router/subscription.go
  • app/config/config_test.go
  • app/common/config.go
  • cmd/server/main.go
  • openmeter/productcatalog/plan/httpdriver/mapping.go
  • openmeter/server/router/router.go
  • openmeter/productcatalog/subscription/http/change.go
  • e2e/productcatalog_test.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/plan/httpdriver/plan.go

Comment thread openmeter/productcatalog/plan.go Resolved
Comment thread openmeter/server/router/router.go Resolved
Comment thread openmeter/server/router/subscription.go Resolved
Comment thread app/config/credit.go Resolved

@turip turip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional issues:

  • UpdatePlan is missing the credit_only guard entirely. plan.go:160-186 — the UpdatePlan handler doesn't validate credit_only settlement mode at all. A user could create a plan with credit_then_invoice, then update it to credit_only even when credits are disabled.
  • For e2e tests, let's add the credits.enabled=false into the configuration file and add a comment that the e2e tc is depending on that.

Comment thread app/config/credits.go Resolved
@mark-vass-konghq
mark-vass-konghq force-pushed the feat/add-settlement-mode-to-v1-api-handlers branch from d347f32 to db89d36 Compare April 1, 2026 12:51
@mark-vass-konghq
mark-vass-konghq force-pushed the feat/add-settlement-mode-to-v1-api-handlers branch from db89d36 to fb4023a Compare April 1, 2026 13:20
@mark-vass-konghq

Copy link
Copy Markdown
Contributor Author

@tothandras, @turip comments are resolved

@tothandras
tothandras merged commit b5036c9 into main Apr 1, 2026
23 of 24 checks passed
@tothandras
tothandras deleted the feat/add-settlement-mode-to-v1-api-handlers branch April 1, 2026 13:46
@coderabbitai coderabbitai Bot mentioned this pull request Apr 7, 2026

This branch was previously deployed

1 inactive deployment
dev — fb4023a8 Deployed Apr 1, 2026 by mark-vass-konghq via Migration Checks #13091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants