Skip to content

Add monetized subscription support gateway#1715

Open
nisan-abeywickrama wants to merge 1 commit intowso2:mainfrom
nisan-abeywickrama:monetization-gw
Open

Add monetized subscription support gateway#1715
nisan-abeywickrama wants to merge 1 commit intowso2:mainfrom
nisan-abeywickrama:monetization-gw

Conversation

@nisan-abeywickrama
Copy link
Copy Markdown
Contributor

Purpose

This pull request introduces support for tracking billing customer and subscription identifiers across the gateway subscription lifecycle. The changes span API definitions, database schema, models, storage, event handling, and analytics, ensuring that billing information is consistently captured, stored, and surfaced for analytics and operational needs. Additionally, the schema version for both SQLite and Postgres is bumped to accommodate these new fields.

Approach

Billing Information Support

  • Added billingCustomerId and billingSubscriptionId fields to the OpenAPI spec for subscriptions, with descriptions indicating their use for analytics tracking. [1] [2]
  • Extended the Subscription model, event payloads, and handlers to include these new billing fields, ensuring they are populated and returned in API responses. [1] [2] [3] [4] [5]

Database Schema and Storage Updates

  • Updated both Postgres and SQLite schema files to add billing_customer_id and billing_subscription_id columns to the subscriptions table, and incremented the schema version to 2. All relevant SQL queries and storage logic are updated to handle these new fields. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Event Propagation and xDS Snapshot

  • Ensured that billing fields are propagated in event payloads and handled in the subscription event consumer, as well as included in the xDS subscription snapshot for downstream systems. [1] [2]

Analytics and Metadata

  • Introduced new metadata keys for billing and subscription status/plan name, and updated analytics event preparation to include these fields in the analytics DTO. [1] [2]

Dependency Updates

  • Upgraded the github.com/wso2/api-platform/sdk/core dependency to v0.2.12 in both controller and runtime to ensure compatibility with the new fields. [1] [2]

Test and Versioning Adjustments

  • Updated tests and schema version assertions to reflect the new schema version and ensure correctness. [1] [2] [3]

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 20, 2026

Warning

Rate limit exceeded

@nisan-abeywickrama has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 58 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99a587b7-07ae-4ff8-b9e0-d805b210eef8

📥 Commits

Reviewing files that changed from the base of the PR and between 661e12f and 3890f3d.

⛔ Files ignored due to path filters (2)
  • gateway/gateway-controller/go.sum is excluded by !**/*.sum and included by **/**
  • gateway/gateway-runtime/policy-engine/go.sum is excluded by !**/*.sum and included by **/**
📒 Files selected for processing (22)
  • gateway/gateway-controller/api/management-openapi.yaml
  • gateway/gateway-controller/go.mod
  • gateway/gateway-controller/pkg/api/handlers/subscription_handler.go
  • gateway/gateway-controller/pkg/api/management/generated.go
  • gateway/gateway-controller/pkg/controlplane/client.go
  • gateway/gateway-controller/pkg/controlplane/events.go
  • gateway/gateway-controller/pkg/models/subscription.go
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.postgres.sql
  • gateway/gateway-controller/pkg/storage/gateway-controller-db.sql
  • gateway/gateway-controller/pkg/storage/sql_store.go
  • gateway/gateway-controller/pkg/storage/sqlite.go
  • gateway/gateway-controller/pkg/storage/sqlite_test.go
  • gateway/gateway-controller/pkg/subscriptionxds/subscription_snapshot.go
  • gateway/gateway-controller/tests/integration/schema_test.go
  • gateway/gateway-runtime/policy-engine/go.mod
  • gateway/gateway-runtime/policy-engine/internal/analytics/analytics.go
  • gateway/gateway-runtime/policy-engine/internal/analytics/constants.go
  • gateway/gateway-runtime/policy-engine/internal/analytics/dto/event.go
  • gateway/gateway-runtime/policy-engine/internal/analytics/dto/subscription.go
  • gateway/gateway-runtime/policy-engine/internal/analytics/dto/unwrappedEvent.go
  • gateway/gateway-runtime/policy-engine/internal/analytics/publishers/moesif.go
  • gateway/system-policies/analytics/analytics.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant