Skip to content

Add monetized subscription data to xds#1709

Merged
nisan-abeywickrama merged 1 commit intowso2:mainfrom
nisan-abeywickrama:monetization-sdk
Apr 20, 2026
Merged

Add monetized subscription data to xds#1709
nisan-abeywickrama merged 1 commit intowso2:mainfrom
nisan-abeywickrama:monetization-sdk

Conversation

@nisan-abeywickrama
Copy link
Copy Markdown
Contributor

Purpose

This pull request adds support for storing and tracking additional billing and plan information in subscription data structures. The changes ensure that each subscription now includes plan name and billing identifiers, making it easier to associate subscriptions with billing records and plans.

Approach

Enhancements to subscription data structures:

  • Added PlanName, BillingCustomerId, and BillingSubscriptionId fields to the SubscriptionData struct in subscription_xds.go to store plan and billing information.
  • Added corresponding PlanName, BillingCustomerID, and BillingSubscriptionID fields to the SubscriptionEntry struct in subscription_store.go to mirror the new data.

Synchronization of new fields:

  • Updated the ReplaceAll method in SubscriptionStore (subscription_store.go) to copy the new plan and billing fields from SubscriptionData into SubscriptionEntry.

@nisan-abeywickrama nisan-abeywickrama changed the title Add subscription data to xds Add monetized subscription data to xds Apr 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Summary

This pull request extends the subscription data structures to include billing and plan information, enabling better tracking of subscription-to-billing associations.

Changes

subscription_xds.go:

  • Added three optional fields to the SubscriptionData struct:
    • PlanName (string)
    • BillingCustomerId (optional string pointer)
    • BillingSubscriptionId (optional string pointer)
  • Fields are serializable via JSON/YAML with corresponding tags

subscription_store.go:

  • Extended the SubscriptionEntry struct with the same three fields as SubscriptionData
  • Updated the ReplaceAll method to populate these new fields when building in-memory subscription entries from the incoming data
  • Existing lookup and validation logic remains unchanged

Outcome

Subscriptions now carry billing and plan metadata alongside their existing status and quota information, allowing the system to associate individual subscriptions with their corresponding billing records and plans.

Walkthrough

The subscription store and subscription data structures are extended with billing-related fields. SubscriptionData adds three new optional fields (PlanName, BillingCustomerId, BillingSubscriptionId), and SubscriptionEntry is updated to expose these fields. The ReplaceAll function populates these new fields when building subscription entries.

Changes

Cohort / File(s) Summary
Subscription Data Structure
sdk/core/policyengine/subscription_xds.go
Added three new optional fields (PlanName, BillingCustomerId, BillingSubscriptionId) to SubscriptionData struct with JSON/YAML serialization tags.
Subscription Store
sdk/core/policyengine/subscription_store.go
Extended SubscriptionEntry struct with PlanName and optional billing identifier fields (BillingCustomerID, BillingSubscriptionID). Updated ReplaceAll function to populate these fields from SubscriptionData during entry initialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers Purpose and Approach comprehensively, but lacks several required template sections including Goals, User stories, Documentation, Automation tests, Security checks, Samples, Related PRs, and Test environment. Add missing sections from the template: Goals, User stories, Documentation, Automation tests (unit and integration), Security checks, Samples, Related PRs, and Test environment information.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add monetized subscription data to xds' clearly and accurately describes the main change: adding new billing and plan fields to subscription data structures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
sdk/core/policyengine/subscription_xds.go (1)

28-36: Align Go field naming: use BillingCustomerID and BillingSubscriptionID to match SubscriptionEntry.

The new fields are well-formed, but SubscriptionData uses BillingCustomerId / BillingSubscriptionId (lowercase 'd') while the matching fields on SubscriptionEntry in subscription_store.go are spelled BillingCustomerID / BillingSubscriptionID (uppercase 'D'). This inconsistency makes find-and-replace fragile across the codebase. The JSON tags can remain lowercase (billingCustomerId/billingSubscriptionId) to preserve wire format; only the Go field names need alignment.

Note: Both structs already use *string for the billing fields consistently, so the pointer type is not an issue. The nullable semantics distinguish "explicitly null" from "empty string" over the wire, which is intentional.

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

In `@sdk/core/policyengine/subscription_xds.go` around lines 28 - 36, The Go field
names in SubscriptionData should be renamed from BillingCustomerId and
BillingSubscriptionId to BillingCustomerID and BillingSubscriptionID to match
the fields on SubscriptionEntry (in subscription_store.go); keep the json and
yaml tags unchanged (billingCustomerId/billingSubscriptionId) and preserve the
*string pointer types and comments so only the identifier casing changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sdk/core/policyengine/subscription_xds.go`:
- Around line 28-36: The Go field names in SubscriptionData should be renamed
from BillingCustomerId and BillingSubscriptionId to BillingCustomerID and
BillingSubscriptionID to match the fields on SubscriptionEntry (in
subscription_store.go); keep the json and yaml tags unchanged
(billingCustomerId/billingSubscriptionId) and preserve the *string pointer types
and comments so only the identifier casing changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1da6b4b3-79b5-4b75-80c9-f3c4b6c5a47c

📥 Commits

Reviewing files that changed from the base of the PR and between 9e20432 and 05393d8.

📒 Files selected for processing (2)
  • sdk/core/policyengine/subscription_store.go
  • sdk/core/policyengine/subscription_xds.go

@nisan-abeywickrama nisan-abeywickrama merged commit 661e12f into wso2:main Apr 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants