Skip to content

Conversation

@athul-rs
Copy link
Contributor

What

Code updates to support unstract payments.
Updates:

  • Organization middleware update to support webhook endpoint.
  • X2-text Adapter cloud plugin support.

Why

  • Changes are introduced to support unstract payments in cloud.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

  • YES, Changes in middleware could cause URLs to break if not handled correctly.
  • Adapter related changes could cause issues to regular flow.

How

  • Introduced additional field for cloud level support to get key.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

Database Migrations

Env Config

Relevant Docs

Related Issues or PRs

Dependencies Versions

Notes on Testing

Screenshots

Checklist

I have read and understood the Contribution Guidelines.

tahierhussain and others added 28 commits January 8, 2025 09:26
…s-and-transform-llmwhisperer-v2-schema-for-cloud
…form-llmwhisperer-v2-schema-for-cloud' of github.com:Zipstack/unstract into feat/support-readonly-for-custom-rjsf-widgets-and-transform-llmwhisperer-v2-schema-for-cloud
…s-and-transform-llmwhisperer-v2-schema-for-cloud
…s-and-transform-llmwhisperer-v2-schema-for-cloud
…form-llmwhisperer-v2-schema-for-cloud' of github.com:Zipstack/unstract
@athul-rs athul-rs requested review from a team, muhammad-ali-e and pk-zipstack and removed request for a team January 23, 2025 11:07
@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

filepath function $$\textcolor{#23d18b}{\tt{passed}}$$ SUBTOTAL
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_logs}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup\_skip}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_client\_init}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image\_exists}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config\_without\_mount}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_run\_container}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{TOTAL}}$$ $$\textcolor{#23d18b}{\tt{9}}$$ $$\textcolor{#23d18b}{\tt{9}}$$

Copy link
Contributor

@muhammad-ali-e muhammad-ali-e left a comment

Choose a reason for hiding this comment

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

LGTM

@jaseemjaskp jaseemjaskp merged commit 01f0e65 into main Jan 24, 2025
6 checks passed
@jaseemjaskp jaseemjaskp deleted the feat/unstract-payments branch January 24, 2025 04:32
pk-zipstack pushed a commit that referenced this pull request Aug 20, 2025
* Implemented changes related to unstract subscription

* Have different home pages for OSS and Cloud

* Renamed the unstract subscription pages and replaced '<></>' with '<Outlet />'

* Updated import path of the TrialDaysInfo component

* Support 'readonly' parameter for all custom RJSF widgets

* Transform the JSON schema for the LLM Whisperer V2 adapter for cloud

* Fixed Eslint issues

* Code quality improvement

* Allow JSON schema transform for LLMW V2 only for paid plan users

* Allow JSON schema transform for LLMW V2 only for paid plan users

* Fix sonar issue

* Implemented the  to structure the API path

* Rearranged the onboard and subscription check APIs

* Unstract payment supporting updates

* X2text metadata updates

* Adapter update for unstarct payments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Minor fix in the API path

* Review comments updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Tahier Hussain <[email protected]>
Co-authored-by: Tahier Hussain <[email protected]>
Co-authored-by: vishnuszipstack <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
athul-rs added a commit that referenced this pull request Nov 10, 2025
This commit adds comprehensive support for admins to create custom Stripe
subscription products for both Unstract and LLM Whisperer platforms.

## Frontend Changes

### Router Updates (Router.jsx)
- Added dynamic import for LlmWhispererCustomCheckoutPage plugin component
- Added public route `/llm-whisperer/custom-checkout` for LLM Whisperer
  custom plan checkout flow
- Follows existing pattern with try/catch for Cloud-only features

### Main App Routes (useMainAppRoutes.js)
- Added Unstract administration route at `/administration`
- Protected with RequireAdmin wrapper (admin-only access)
- Imported UnstractAdministrationPage component

### New Administration Page (UnstractAdministrationPage.jsx)
- Plugin-loader pattern with try/catch for Cloud-only component
- Falls back to "feature not available" message in OSS builds
- Dynamically imports UnstractAdministration from Cloud plugins

## Backend Changes (Already Committed)

The backend infrastructure was already added in previous commits:

### Subscription Routes (cloud_urls_v2.py)
- Unstract admin endpoint: `/api/v1/unstract/admin/stripe/products/dynamic/`
- LLM Whisperer admin endpoint: `/api/v1/llmwhisperer/admin/stripe/products/dynamic/portal/`

### Portal Proxy (subscription_v2/views.py)
- `create_dynamic_stripe_product_portal_proxy()` method forwards LLM Whisperer
  admin requests to Portal service
- Follows existing LLMWhispererService pattern for multi-backend architecture
- Includes proper error handling and logging

### URL Patterns (subscription_v2/urls.py)
- Added `admin_stripe_product_portal_proxy` view and URL pattern
- Both endpoints protected with IsAuthenticated + IsAdmin permissions

## Architecture

This implementation follows Unstract's plugin-based architecture:
- OSS repo contains base routing and plugin-loader patterns
- Cloud repo contains actual admin UI components (subscription-admin plugin)
- Multi-backend support: Unstract uses local backend, LLM Whisperer proxies
  to Portal service
- Graceful degradation for OSS builds (shows "Cloud-only feature" message)

## Related
- Supersedes PR #1087 (monolithic admin UI)
- Integrates checkout functionality from PR #1016
- Consolidates router changes from PR #1558

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
johnyrahul added a commit that referenced this pull request Nov 13, 2025
* feat: Add admin custom Stripe product creation support

This commit adds comprehensive support for admins to create custom Stripe
subscription products for both Unstract and LLM Whisperer platforms.

## Frontend Changes

### Router Updates (Router.jsx)
- Added dynamic import for LlmWhispererCustomCheckoutPage plugin component
- Added public route `/llm-whisperer/custom-checkout` for LLM Whisperer
  custom plan checkout flow
- Follows existing pattern with try/catch for Cloud-only features

### Main App Routes (useMainAppRoutes.js)
- Added Unstract administration route at `/administration`
- Protected with RequireAdmin wrapper (admin-only access)
- Imported UnstractAdministrationPage component

### New Administration Page (UnstractAdministrationPage.jsx)
- Plugin-loader pattern with try/catch for Cloud-only component
- Falls back to "feature not available" message in OSS builds
- Dynamically imports UnstractAdministration from Cloud plugins

## Backend Changes (Already Committed)

The backend infrastructure was already added in previous commits:

### Subscription Routes (cloud_urls_v2.py)
- Unstract admin endpoint: `/api/v1/unstract/admin/stripe/products/dynamic/`
- LLM Whisperer admin endpoint: `/api/v1/llmwhisperer/admin/stripe/products/dynamic/portal/`

### Portal Proxy (subscription_v2/views.py)
- `create_dynamic_stripe_product_portal_proxy()` method forwards LLM Whisperer
  admin requests to Portal service
- Follows existing LLMWhispererService pattern for multi-backend architecture
- Includes proper error handling and logging

### URL Patterns (subscription_v2/urls.py)
- Added `admin_stripe_product_portal_proxy` view and URL pattern
- Both endpoints protected with IsAuthenticated + IsAdmin permissions

## Architecture

This implementation follows Unstract's plugin-based architecture:
- OSS repo contains base routing and plugin-loader patterns
- Cloud repo contains actual admin UI components (subscription-admin plugin)
- Multi-backend support: Unstract uses local backend, LLM Whisperer proxies
  to Portal service
- Graceful degradation for OSS builds (shows "Cloud-only feature" message)

## Related
- Supersedes PR #1087 (monolithic admin UI)
- Integrates checkout functionality from PR #1016
- Consolidates router changes from PR #1558

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* chore: Add NOSONAR comments for plugin loading pattern

Suppress SonarQube warnings for intentional empty catch blocks used in
plugin loading architecture. These catch blocks are part of the graceful
degradation pattern for Cloud-only features - when plugins are not available,
the component remains undefined and React Router triggers NotFound page.

This pattern is used throughout the codebase for optional plugin loading.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* style: Fix Prettier formatting for NOSONAR comments

Move NOSONAR comments to separate lines to comply with Prettier formatting rules.
Format multi-line Route component in useMainAppRoutes.js.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: Correct NOSONAR comment placement for SonarQube

Place NOSONAR comment inline with catch statement for proper recognition.
SonarQube requires the suppression comment on the same line as the issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: Add NOSONAR comments to suppress empty catch warnings

Add minimal NOSONAR comments to suppress SonarQube warnings for intentional
empty catch blocks in plugin loading pattern. These catch blocks are part of
the graceful degradation architecture for Cloud-only features.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* path modified admin cusotm plans

* UN-2861 [FEAT] Add RequireStaff permission for custom plans administration

Add platform staff-only access control for custom Unstract subscription plans:
- Add RequireStaff component to enforce platform staff access
- Update custom plans route to use RequireStaff instead of RequireAdmin
- Block access for open-source deployments (mock_org)

Frontend Changes:
- New RequireStaff.js component with isStaff and orgName validation
- Update useMainAppRoutes.js to use RequireStaff for /admin/custom-plans route
- Shows Unauthorized for non-staff users, NotFound for OSS deployments

This complements the backend IsStaff permission class to ensure only platform
staff can create custom Stripe products with dual pricing structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Remove unused RequireStaff component

Remove RequireStaff component as it's been replaced with inline staff
checking pattern in route files. This avoids component dependency issues
and follows the established Verticals pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Remove RequireStaff dependency from OSS routes

Replace RequireStaff component wrapper with inline staff check using
useSessionStore in an IIFE. This matches the pattern used in Cloud
plugin routes and fixes the build error where RequireStaff component
was deleted but still referenced.

The inline check ensures:
- Staff-only access to admin custom plans route
- Hidden in open-source deployments (orgName === "mock_org")
- No component import dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Fix Prettier formatting for staff check return statement

* Refactor inline CSS to classes in UnstractAdministrationPage

- Create UnstractAdministrationPage.css for fallback UI styling
- Replace inline styles with className in UnstractAdministrationPage.jsx
- Improves code maintainability and follows project's CSS patterns

* Fix React Rules of Hooks violation in useMainAppRoutes

- Move useSessionStore hook call to top level of function
- Remove IIFE pattern that violated hooks rules
- Simplify conditional rendering logic

Fixes CodeRabbit review comment about hooks being called inside nested function.

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Rahul Johny <[email protected]>
johnyrahul pushed a commit that referenced this pull request Nov 14, 2025
* feat: Add admin custom Stripe product creation support

This commit adds comprehensive support for admins to create custom Stripe
subscription products for both Unstract and LLM Whisperer platforms.

## Frontend Changes

### Router Updates (Router.jsx)
- Added dynamic import for LlmWhispererCustomCheckoutPage plugin component
- Added public route `/llm-whisperer/custom-checkout` for LLM Whisperer
  custom plan checkout flow
- Follows existing pattern with try/catch for Cloud-only features

### Main App Routes (useMainAppRoutes.js)
- Added Unstract administration route at `/administration`
- Protected with RequireAdmin wrapper (admin-only access)
- Imported UnstractAdministrationPage component

### New Administration Page (UnstractAdministrationPage.jsx)
- Plugin-loader pattern with try/catch for Cloud-only component
- Falls back to "feature not available" message in OSS builds
- Dynamically imports UnstractAdministration from Cloud plugins

## Backend Changes (Already Committed)

The backend infrastructure was already added in previous commits:

### Subscription Routes (cloud_urls_v2.py)
- Unstract admin endpoint: `/api/v1/unstract/admin/stripe/products/dynamic/`
- LLM Whisperer admin endpoint: `/api/v1/llmwhisperer/admin/stripe/products/dynamic/portal/`

### Portal Proxy (subscription_v2/views.py)
- `create_dynamic_stripe_product_portal_proxy()` method forwards LLM Whisperer
  admin requests to Portal service
- Follows existing LLMWhispererService pattern for multi-backend architecture
- Includes proper error handling and logging

### URL Patterns (subscription_v2/urls.py)
- Added `admin_stripe_product_portal_proxy` view and URL pattern
- Both endpoints protected with IsAuthenticated + IsAdmin permissions

## Architecture

This implementation follows Unstract's plugin-based architecture:
- OSS repo contains base routing and plugin-loader patterns
- Cloud repo contains actual admin UI components (subscription-admin plugin)
- Multi-backend support: Unstract uses local backend, LLM Whisperer proxies
  to Portal service
- Graceful degradation for OSS builds (shows "Cloud-only feature" message)

## Related
- Supersedes PR #1087 (monolithic admin UI)
- Integrates checkout functionality from PR #1016
- Consolidates router changes from PR #1558

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* chore: Add NOSONAR comments for plugin loading pattern

Suppress SonarQube warnings for intentional empty catch blocks used in
plugin loading architecture. These catch blocks are part of the graceful
degradation pattern for Cloud-only features - when plugins are not available,
the component remains undefined and React Router triggers NotFound page.

This pattern is used throughout the codebase for optional plugin loading.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* style: Fix Prettier formatting for NOSONAR comments

Move NOSONAR comments to separate lines to comply with Prettier formatting rules.
Format multi-line Route component in useMainAppRoutes.js.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: Correct NOSONAR comment placement for SonarQube

Place NOSONAR comment inline with catch statement for proper recognition.
SonarQube requires the suppression comment on the same line as the issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: Add NOSONAR comments to suppress empty catch warnings

Add minimal NOSONAR comments to suppress SonarQube warnings for intentional
empty catch blocks in plugin loading pattern. These catch blocks are part of
the graceful degradation architecture for Cloud-only features.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* path modified admin cusotm plans

* UN-2861 [FEAT] Add RequireStaff permission for custom plans administration

Add platform staff-only access control for custom Unstract subscription plans:
- Add RequireStaff component to enforce platform staff access
- Update custom plans route to use RequireStaff instead of RequireAdmin
- Block access for open-source deployments (mock_org)

Frontend Changes:
- New RequireStaff.js component with isStaff and orgName validation
- Update useMainAppRoutes.js to use RequireStaff for /admin/custom-plans route
- Shows Unauthorized for non-staff users, NotFound for OSS deployments

This complements the backend IsStaff permission class to ensure only platform
staff can create custom Stripe products with dual pricing structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Remove unused RequireStaff component

Remove RequireStaff component as it's been replaced with inline staff
checking pattern in route files. This avoids component dependency issues
and follows the established Verticals pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Remove RequireStaff dependency from OSS routes

Replace RequireStaff component wrapper with inline staff check using
useSessionStore in an IIFE. This matches the pattern used in Cloud
plugin routes and fixes the build error where RequireStaff component
was deleted but still referenced.

The inline check ensures:
- Staff-only access to admin custom plans route
- Hidden in open-source deployments (orgName === "mock_org")
- No component import dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Fix Prettier formatting for staff check return statement

* Refactor inline CSS to classes in UnstractAdministrationPage

- Create UnstractAdministrationPage.css for fallback UI styling
- Replace inline styles with className in UnstractAdministrationPage.jsx
- Improves code maintainability and follows project's CSS patterns

* Fix React Rules of Hooks violation in useMainAppRoutes

- Move useSessionStore hook call to top level of function
- Remove IIFE pattern that violated hooks rules
- Simplify conditional rendering logic

Fixes CodeRabbit review comment about hooks being called inside nested function.

* Fix admin route loading by always registering route

- Always register admin/custom-plans route (no conditional)
- Move staff permission check to UnstractAdministrationPage component
- Check permissions at render time when session is loaded
- Fixes route registration timing issue

This ensures route exists and is accessible to staff users while
maintaining security through component-level permission checks.

* Add loading state check to UnstractAdministrationPage

- Add null check for sessionDetails before authorization
- Prevents premature access denial during session load
- Addresses CodeRabbit feedback on loading state
- Maintains existing orgName === "mock_org" pattern consistent with RequireAdmin and usePostHogEvents

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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.

7 participants