Repository navigation
feat(billing): add customer billing profile selection endpoint - #5357
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Define the billing-profile contract api/spec/packages/aip/src/customers/*, api/spec/packages/aip-client-javascript/src/models/*, api/v3/api.gen.go, api/v3/client/models_customers.go |
The API and client models represent the selected profile as optional and nullable, and the effective profile as a separate value. The generated API registers the profile-update route. |
Implement the profile update endpoint api/v3/handlers/customers/billing/*, api/v3/server/routes.go, api/v3/api.gen.go |
The handler assigns or clears a customer profile override, resolves the resulting profile under a customer lock, and returns the selected and effective profiles. |
Expose the operation in client libraries and documentation api/spec/packages/aip-client-javascript/README.md, api/spec/packages/aip-client-javascript/src/funcs/customers.ts, api/spec/packages/aip-client-javascript/src/sdk/customers.ts, api/spec/packages/aip-client-javascript/src/index.ts, api/spec/packages/aip-client-javascript/src/models/operations/customers.ts, api/v3/client/customers_billing.go, api/v3/client/README.md, openmeter/billing/README.md |
The JavaScript and Go clients add profile-update methods. Documentation distinguishes updates that preserve the selection from the dedicated operation that clears it when the field is omitted or null. |
Validate profile selection behavior test/app/stripe/customerbilling_profile_v3_test.go, test/app/stripe/customerbilling_v3_test.go, e2e/billinginvoice_override_test.go, e2e/billinginvoices_v3_test.go |
Tests cover selection, clearing, default-profile changes, invalid references, and nullable profile values. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Client
participant UpdateCustomerBillingProfile
participant BillingService
Client->>UpdateCustomerBillingProfile: PUT profile selection
UpdateCustomerBillingProfile->>BillingService: Assign or clear customer override
BillingService-->>UpdateCustomerBillingProfile: Resolved customer billing profile
UpdateCustomerBillingProfile-->>Client: CustomerProfile response
Possibly related PRs
- openmeterio/openmeter#5342: Establishes the pinned-versus-effective profile contract extended by this change.
- openmeterio/openmeter#5348: Introduces the billing-profile service and assignment model used by the new endpoint.
- openmeterio/openmeter#5349: Deprecates legacy customer workflow and tax override fields in favor of billing-profile assignment.
Suggested reviewers: tothandras, galexihu, borosr
Merge Risk: 
Minimal · up to 2184e
-
The change adds an endpoint to set or clear a customer's billing profile selection, and the generated API and client types follow that contract. No concrete merge-blocking risk was identified from the supplied evidence.
Pre-merge checks: 
4
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
021260b to
2538d10
Compare
ace4497 to
5cfb99d
Compare
5cfb99d to
c35eac4
Compare
c35eac4 to
d542386
Compare
d542386 to
2184ec8
Compare
Overview
Add
PUT /openmeter/customers/{customerId}/billing/profileto replace a customer's billing profile selection independently of app data. Providingbilling_profile.idsets a pin; omittingbilling_profileor sendingnullclears it and resumes following the namespace default.The response includes the optional explicit selection and required read-only
effective_billing_profile, matching billing GET. ComposeCustomerBillingDatafrom the shared profile model and app data, and regenerate the API and clients.Notes for reviewer
Uses the set/clear billing profile assignment services. The combined billing PUT continues preserving the pin when the profile is omitted or null.
Clearing is idempotent and runs with response resolution in the existing locked transaction, so a missing default rolls back the unpin. Tests cover explicit default pins, subsequent default changes, app-data preservation, invalid references, missing/deleted customers, repeated clearing, and rollback.
Validation: PostgreSQL-backed billing HTTP, assignment service, and default-profile-change tests; scoped fast Go lint and vet; Go SDK tests; TypeScript SDK typecheck and 552 tests; e2e compilation; API regeneration and TypeSpec formatting.
Summary by CodeRabbit
billing_profileis omitted or null.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Adds
PUT /openmeter/customers/{customerId}/billing/profileto change a customer's profile selection without changing app data.No actionable issues were found. Tests were inspected but not run.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[PUT billing/profile] --> B[Check request and customer] B --> C[Start locked transaction] C --> D{Profile ID supplied?} D -->|Yes| E[Set explicit selection] D -->|No| F[Clear explicit selection] F --> G[Look up current default] E --> H[Commit and return profile] G --> H G -->|Lookup fails| I[Roll back selection change]Reviews (5) · Last reviewed commit: "feat(billing): add customer billing prof..." · Reviewed by Greptile