Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
71e1369
fix(api): settlement mode
tothandras Jun 1, 2026
9d8ffba
fix: pass down the settlement mode to the PlanSubscriptionService
borosr Jun 1, 2026
de8c263
fix: pass through settlement mode for subscription create and change
rolosp Jun 1, 2026
9bbc36a
test: extended unit and e2e test for subscription create and change
rolosp Jun 1, 2026
58448b9
refactor: move creditEnabled check up
rolosp Jun 1, 2026
5e56138
feat: add credits enabled and sttlement mode check to v3 subscription…
rolosp Jun 1, 2026
60972c6
fix: failing tests
borosr Jun 1, 2026
42e7bc3
chore: fixed error messages for subscription change
rolosp Jun 2, 2026
40e67ec
test: fixed failign e2e test
rolosp Jun 2, 2026
9f753b5
refactor: make the feature gate context base in the http processing f…
borosr Jun 3, 2026
b9e9f5d
feat: add tests
borosr Jun 3, 2026
60c2dea
fix: featureGate config value
borosr Jun 3, 2026
5e26c51
refactor: remove FeatureFlag from credits configuration
borosr Jun 3, 2026
328f3b9
refactor: improve validation to handle nil case
borosr Jun 4, 2026
1f9500c
fix: failing tests and resolve linter
borosr Jun 4, 2026
ac3c9eb
fix: failing tests and resolve error message to be 400
borosr Jun 4, 2026
e9150b3
fix: error message
borosr Jun 4, 2026
5050920
refactor: add settlement mode to the v3 responses
borosr Jun 4, 2026
fc0ad42
fix: failing e2e tests
borosr Jun 4, 2026
bf7ffbf
refactor: intorduce flag overrides to handle viper based configs
borosr Jun 5, 2026
b5074a9
fix: failing e2e tests and simplify Credits resolver function
borosr Jun 5, 2026
8fa62e8
fix: failing tests
borosr Jun 5, 2026
6fbaf20
fix: failing e2e tests
borosr Jun 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,175 changes: 589 additions & 586 deletions api/api.gen.go

Large diffs are not rendered by default.

1,167 changes: 585 additions & 582 deletions api/client/go/client.gen.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions api/client/javascript/src/client/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9891,6 +9891,8 @@ export interface components {
* @example 2023-01-01T01:01:01.001Z
*/
billingAnchor?: Date
/** @description The settlement mode of the subscription. */
settlementMode?: components['schemas']['BillingSettlementMode']
}
/**
* Create from plan
Expand All @@ -9912,6 +9914,8 @@ export interface components {
name?: string
/** @description Description for the Subscription. */
description?: string
/** @description The settlement mode of the subscription. */
settlementMode?: components['schemas']['BillingSettlementMode']
/**
* @description Timing configuration for the change, when the change should take effect.
* The default is immediate.
Expand All @@ -9931,8 +9935,6 @@ export interface components {
* @example 2023-01-01T01:01:01.001Z
*/
billingAnchor?: Date
/** @description The settlement mode of the subscription. */
settlementMode?: components['schemas']['BillingSettlementMode']
}
/**
* @description A consumer portal token.
Expand Down
7 changes: 7 additions & 0 deletions api/client/javascript/src/zod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17228,6 +17228,13 @@ export const ChangeSubscriptionBody = zod
'References an exact plan defaulting to the current active version.',
)
.describe('The plan reference to change to.'),
settlementMode: zod
.enum(['credit_then_invoice', 'credit_only'])
.describe(
'The settlement mode of a plan.\nIt determines how the billing system generates invoices and credits for the subscriptions using this plan.\n- credit_then_invoice: credits from the previous billing period are applied first, then the remaining balance is invoiced. This is the default and most common settlement mode.\n- credit_only: only credits from the previous billing period are generated and applied. No invoices are generated for the subscription.',
)
.optional()
.describe('The settlement mode of the subscription.'),
startingPhase: zod.coerce
.string()
.min(1)
Expand Down
27 changes: 18 additions & 9 deletions api/client/python/openmeter/_generated/models/_models.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions api/openapi.cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22589,6 +22589,10 @@ components:
format: date-time
description: The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the previous subscription billing anchor will be used.
example: '2023-01-01T01:01:01.001Z'
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
description: Change subscription based on plan.
PlanSubscriptionCreate:
type: object
Expand Down Expand Up @@ -22619,6 +22623,10 @@ components:
description:
type: string
description: Description for the Subscription.
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
timing:
allOf:
- $ref: '#/components/schemas/SubscriptionTiming'
Expand All @@ -22641,10 +22649,6 @@ components:
format: date-time
description: The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the subscription start time will be used.
example: '2023-01-01T01:01:01.001Z'
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
description: Create subscription based on plan.
title: Create from plan
PortalToken:
Expand Down
12 changes: 8 additions & 4 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23372,6 +23372,10 @@ components:
format: date-time
description: The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the previous subscription billing anchor will be used.
example: '2023-01-01T01:01:01.001Z'
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
description: Change subscription based on plan.
PlanSubscriptionCreate:
type: object
Expand Down Expand Up @@ -23402,6 +23406,10 @@ components:
description:
type: string
description: Description for the Subscription.
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
timing:
allOf:
- $ref: '#/components/schemas/SubscriptionTiming'
Expand All @@ -23424,10 +23432,6 @@ components:
format: date-time
description: The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the subscription start time will be used.
example: '2023-01-01T01:01:01.001Z'
settlementMode:
allOf:
- $ref: '#/components/schemas/BillingSettlementMode'
description: The settlement mode of the subscription.
description: Create subscription based on plan.
title: Create from plan
PortalToken:
Expand Down
13 changes: 13 additions & 0 deletions api/spec/packages/aip/src/productcatalog/plan.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ model Plan {
@minItems(1)
phases: PlanPhase[];

/**
* Settlement mode for plan.
*
* Values:
*
* - `credit_then_invoice`: Credits are applied first, then any remainder is
* invoiced.
* - `credit_only`: Usage is settled exclusively against credits.
*/
@visibility(Lifecycle.Read)
@summary("Settlement Mode")
settlement_mode?: ProductCatalog.SettlementMode = ProductCatalog.SettlementMode.CreditThenInvoice;

/**
* List of validation errors in `draft` state that prevent the plan from being
* published.
Expand Down
14 changes: 14 additions & 0 deletions api/spec/packages/aip/src/subscriptions/subscription.tsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "@typespec/openapi";
import "../shared/index.tsp";
import "../productcatalog/ratecard.tsp";

using TypeSpec.OpenAPI;

Expand Down Expand Up @@ -166,4 +167,17 @@ model Subscription {
@visibility(Lifecycle.Read)
@summary("Status")
status: SubscriptionStatus;

/**
* Settlement mode for billing.
*
* Values:
*
* - `credit_then_invoice`: Credits are applied first, then any remainder is
* invoiced.
* - `credit_only`: Usage is settled exclusively against credits.
*/
@visibility(Lifecycle.Create, Lifecycle.Read)
@summary("Settlement Mode")
settlement_mode?: ProductCatalog.SettlementMode = ProductCatalog.SettlementMode.CreditThenInvoice;
}
10 changes: 5 additions & 5 deletions api/spec/packages/legacy/src/productcatalog/subscription.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,6 @@ model PlanSubscriptionCreate {
* The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the subscription start time will be used.
*/
billingAnchor?: DateTime;

/**
* The settlement mode of the subscription.
*/
settlementMode?: SettlementMode;
}

/**
Expand Down Expand Up @@ -513,6 +508,11 @@ model PlanSubscriptionChange {
* The billing anchor of the subscription. The provided date will be normalized according to the billing cadence to the nearest recurrence before start time. If not provided, the previous subscription billing anchor will be used.
*/
billingAnchor?: DateTime;

/**
* The settlement mode of the subscription.
*/
settlementMode?: SettlementMode;
}

/**
Expand Down
Loading
Loading