-
Notifications
You must be signed in to change notification settings - Fork 167
Feat/stripe integration v1 #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a Stripe integration: new StripeBubble service with create_customer, create_subscription, cancel_subscription operations, credential types and UI entries, schema/type exports, factory registration, credential validation mapping, tests, and an integration stress-test flow. Changes
Sequence DiagramssequenceDiagram
participant User
participant BubbleFactory
participant StripeBubble
participant StripeAPI
User->>BubbleFactory: Request instantiate 'stripe' bubble
BubbleFactory->>StripeBubble: Construct StripeBubble(params)
User->>StripeBubble: performAction(create_customer)
StripeBubble->>StripeBubble: chooseCredential()
StripeBubble->>StripeAPI: POST /v1/customers (with API key)
StripeAPI-->>StripeBubble: Response (success or error)
StripeBubble-->>User: StripeResult{ operation, success, data?, error? }
sequenceDiagram
participant Client
participant CredentialValidator
participant StripeBubble
participant StripeAPI
Client->>CredentialValidator: Validate STRIPE_SECRET_KEY
CredentialValidator->>StripeBubble: call testCredential()
StripeBubble->>StripeBubble: chooseCredential()
StripeBubble->>StripeAPI: GET/POST test endpoint
StripeAPI-->>StripeBubble: 200 OK or error
StripeBubble-->>CredentialValidator: boolean result
CredentialValidator-->>Client: validation outcome
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
Suggested PR title from PearlTitle: Body: OverviewAdds Stripe integration support to enable payment processing, customer management, and subscription handling through Stripe's API. ChangesNew Stripe Service Bubble
UI Updates
Infrastructure
Testing
Technical Details
Additional Changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds Stripe payment integration to BubbleLab, enabling customer creation and subscription management through the Stripe API. The implementation follows the established ServiceBubble pattern with credential injection, schema validation, and proper error handling.
Key Changes:
- Adds StripeBubble service with support for creating customers, creating subscriptions, and canceling subscriptions
- Implements credential management for Stripe secret keys through the existing credential system
- Adds
google/gemini-1.5-flashmodel to available AI models
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
packages/bubble-shared-schemas/src/types.ts |
Adds STRIPE_SECRET_KEY credential type and 'stripe' bubble name |
packages/bubble-shared-schemas/src/credential-schema.ts |
Maps Stripe credentials to environment variables and bubble configuration |
packages/bubble-shared-schemas/src/bubble-definition-schema.ts |
Adds Stripe credential configuration mapping |
packages/bubble-shared-schemas/src/ai-models.ts |
Adds google/gemini-1.5-flash model to available models |
packages/bubble-core/src/index.ts |
Exports StripeBubble and its types |
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts |
Core Stripe bubble implementation with API integration |
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.ts |
Basic metadata tests for Stripe bubble |
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.ts |
Duplicate test file that appears to be an example |
packages/bubble-core/src/bubbles/service-bubble/stripe/index.ts |
Re-exports StripeBubble |
packages/bubble-core/src/bubble-factory.ts |
Registers Stripe bubble in factory and adds debug logging |
apps/bubblelab-api/src/services/credential-validator.ts |
Adds credential validation support for Stripe with debug logging |
apps/bubble-studio/src/pages/CredentialsPage.tsx |
Adds UI configuration for Stripe credentials |
apps/bubble-studio/src/lib/integrations.ts |
Adds Stripe to integrations list |
apps/bubble-studio/public/integrations/stripe.svg |
Stripe logo asset |
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.ts
Outdated
Show resolved
Hide resolved
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
Outdated
Show resolved
Hide resolved
| import { describe, expect, test } from 'vitest'; | ||
| import { StripeBubble } from './stripe.js'; | ||
| import { StripeParamsSchema, StripeResultSchema } from './stripe.js'; | ||
|
|
||
| describe('static properties', () => { | ||
| test('should have correct static properties', () => { | ||
| expect(StripeBubble.bubbleName).toBe('stripe'); | ||
| expect(StripeBubble.service).toBe('stripe'); | ||
| expect(StripeBubble.authType).toBe('apikey'); | ||
| expect(StripeBubble.type).toBe('service'); | ||
| expect(StripeBubble.alias).toBe('stripe'); | ||
| expect(StripeBubble.shortDescription).toContain("Stripe's API"); | ||
| expect(StripeBubble.shortDescription).toContain('payments'); | ||
| expect(StripeBubble.shortDescription).toContain('customers'); | ||
| expect(StripeBubble.shortDescription).toContain('subscriptions'); | ||
| expect(StripeBubble.schema).toBe(StripeParamsSchema); | ||
| expect(StripeBubble.resultSchema).toBe(StripeResultSchema); | ||
| }); | ||
|
|
||
| test('should have longDescription with key information', () => { | ||
| const bubble = new StripeBubble({ | ||
| operation: 'create_customer', | ||
| email: 'test@example.com', | ||
| }); | ||
|
|
||
| expect(bubble.longDescription).toContain('Stripe'); | ||
| expect(bubble.longDescription).toContain('API'); | ||
| expect(bubble.longDescription).toContain('customers'); | ||
| expect(bubble.longDescription).toContain('payments'); | ||
| expect(bubble.longDescription).toContain('subscriptions'); | ||
| expect(bubble.longDescription).toContain('API key'); | ||
| expect(bubble.longDescription).toContain('authentication'); | ||
| }); | ||
| }); |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test suite only includes basic metadata tests. Compared to other service bubbles in the codebase (e.g., airtable.test.ts, resend.test.ts), this lacks comprehensive test coverage for:
- Schema validation for different operations (create_customer, create_subscription, cancel_subscription)
- Parameter validation (required vs optional fields)
- Error handling scenarios
- Credential injection and validation
Consider adding more comprehensive unit tests similar to the patterns used in other service bubble tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Fix all issues with AI Agents 🤖
In @apps/bubble-studio/src/lib/integrations.ts:
- Line 14: Add Stripe to the alias, matcher, and docs maps so resolution is
consistent: add "stripe: 'Stripe'" to NAME_ALIASES, add a matcher entry
[/\\bstripe\\b/, 'Stripe'] in the orderedMatchers array inside
findLogoForBubble, and add "stripebubble: 'stripe-bubble'" to
SERVICE_DOCS_BY_CLASS plus "stripe: 'stripe-bubble'" to SERVICE_DOCS_BY_NAME;
ensure the keys and values match the existing naming conventions used for other
services.
In @apps/bubblelab-api/src/services/credential-validator.ts:
- Line 55: Remove the leftover debug console.log statements in
credential-validator.ts (the lines printing "Validating credential for bubble
fietssssssss" and the similar one at the other occurrence) — these are
development artifacts with a typo and can leak info; either delete them or
replace with a proper structured logger call (e.g., processLogger.debug or
logger.debug) without sensitive data. Locate the prints in the validate
credential flow (search for the exact string or console.log in the
credential-validator module) and remove or convert both occurrences to
non-sensitive, configurable debug logging.
In @packages/bubble-core/src/bubble-factory.ts:
- Line 110: Remove the leftover debug console.log in bubble creation: delete the
line "console.log('Creating bubble:', name, BubbleClass)" in bubble-factory.ts
(inside the bubble creation logic where BubbleClass and name are used) or
replace it with a proper logger call that respects a log level (e.g., use the
project's logger and only log at debug/trace when enabled). Ensure you reference
the BubbleClass and name variables in the bubble creation function so logging is
conditional or removed before merging.
🧹 Nitpick comments (3)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (3)
162-173: Avoid passing empty object to GET request.The
testCredentialmethod passes an empty object{}as the body for a GET request. While this works becausemakeStripeApiCallconverts empty objects toundefinedviaURLSearchParams, it's cleaner to explicitly passundefinedfor GET requests.🔎 Proposed fix
public async testCredential(): Promise<boolean> { // Make a test API call to the Stripe API const response = await this.makeStripeApiCall( 'GET', - '/customers?limit=1', - {} + '/customers?limit=1' ); - if (response.success) { - return true; - } - return false; + return response.success; }
186-195: Default parameter type assertion may mask issues.The constructor's default parameter uses a type assertion (
as T) which could mask type mismatches at runtime ifTis narrowed to a specific operation type. Consider whether this default is appropriate for all generic instantiations.
246-304: Consider adding request timeout for external API calls.The
fetchcall to Stripe's API has no timeout configured. Long-running or hanging requests could block indefinitely. Consider usingAbortControllerwith a timeout.🔎 Proposed fix with timeout
private async makeStripeApiCall( httpMethod: 'GET' | 'POST' | 'DELETE' | 'PUT', endpoint: string, body?: Record<string, string> ): Promise<{ success: boolean; data?: unknown; error?: string; }> { const apiKey = this.chooseCredential(); if (!apiKey) { throw new Error('Stripe API key is required'); } const url = `${STRIPE_API_BASE_URL}${endpoint}`; const formattedBody = body ? new URLSearchParams(body).toString() : undefined; const headers: Record<string, string> = { Authorization: `Bearer ${apiKey}`, }; if (formattedBody) { headers['Content-Type'] = 'application/x-www-form-urlencoded'; } + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 30000); // 30s timeout + try { const response = await fetch(url, { method: httpMethod, headers, body: formattedBody, + signal: controller.signal, }); + clearTimeout(timeoutId); const data = await response.json(); // ... rest of the function + } catch (error) { + clearTimeout(timeoutId); + if (error instanceof Error && error.name === 'AbortError') { + throw new Error('Stripe API call timed out'); + } + throw new Error( + `Stripe API call failed: ${error instanceof Error ? error.message : String(error)}` + ); + } }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
apps/bubble-studio/public/integrations/stripe.svgis excluded by!**/*.svg
📒 Files selected for processing (13)
apps/bubble-studio/src/lib/integrations.tsapps/bubble-studio/src/pages/CredentialsPage.tsxapps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/bubble-factory.tspackages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.tspackages/bubble-core/src/index.tspackages/bubble-shared-schemas/src/ai-models.tspackages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-shared-schemas/src/credential-schema.tspackages/bubble-shared-schemas/src/types.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/packages/bubble-shared-schemas/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/api.mdc)
**/packages/bubble-shared-schemas/**/*.{ts,tsx}: Write shared schemas between frontend and backend in/packages/bubble-shared-schemasdirectory
Runpnpm build:coreafter modifying shared schemas since it is a separate package and types need to be regenerated
Files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-shared-schemas/src/types.tspackages/bubble-shared-schemas/src/credential-schema.tspackages/bubble-shared-schemas/src/ai-models.ts
packages/bubble-core/src/index.ts
📄 CodeRabbit inference engine (.cursor/rules/bundling.mdc)
All new types and classes added to bubble-core must be exported from
packages/bubble-core/src/index.tsto ensure they are included in the generated bundle
Files:
packages/bubble-core/src/index.ts
🧠 Learnings (15)
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: When adding new types to `bubblelab/shared-schemas`, they are automatically included in the bundle without requiring manual configuration changes
Applied to files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-shared-schemas/src/types.tspackages/bubble-shared-schemas/src/ai-models.tspackages/bubble-core/src/index.ts
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/packages/bubble-shared-schemas/**/*.{ts,tsx} : Write shared schemas between frontend and backend in `/packages/bubble-shared-schemas` directory
Applied to files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-shared-schemas/src/types.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.tspackages/bubble-core/src/index.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/src/index.ts : All new types and classes added to bubble-core must be exported from `packages/bubble-core/src/index.ts` to ensure they are included in the generated bundle
Applied to files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-shared-schemas/src/types.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.tsapps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/index.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to apps/bubble-studio/public/bubble-types.txt : The bundle file at `apps/bubble-studio/public/bubble-types.txt` must be kept synchronized with `packages/bubble-core/dist/bubble-bundle.d.ts` after each build
Applied to files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-shared-schemas/src/types.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.tsapps/bubble-studio/src/lib/integrations.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.tsapps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/index.tsapps/bubble-studio/src/pages/CredentialsPage.tsxpackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-runtime/src/injection/README.md : Refer to packages/bubble-runtime/src/injection/README.md for information about credential injection and bubble parameter reinitialization
Applied to files:
packages/bubble-shared-schemas/src/bubble-definition-schema.tspackages/bubble-shared-schemas/src/credential-schema.tsapps/bubblelab-api/src/services/credential-validator.tsapps/bubble-studio/src/pages/CredentialsPage.tsxpackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/dist/**/*.d.ts : All external imports (except relative imports) must be removed from the bundled output to prevent circular processing and external dependency issues
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-core/src/index.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/dist/**/*.d.ts : The type bundling system for Monaco Editor must process TypeScript declaration files (.d.ts) and inline all dependencies into a single self-contained bundle in `packages/bubble-core/dist/bubble-bundle.d.ts`
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.tspackages/bubble-core/src/index.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to apps/bubble-studio/src/components/MonacoEditor.tsx : The Monaco Editor integration in `apps/bubble-studio/src/components/MonacoEditor.tsx` must fetch the bundled types from `/bubble-types.txt`, wrap them in a module declaration for `bubblelab/bubble-core`, and add them to Monaco's TypeScript type system
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-core/src/index.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/scripts/bubble-bundler.ts : The bundler script at `packages/bubble-core/scripts/bubble-bundler.ts` must use absolute file paths as cache keys to prevent collisions between packages with identically named files
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/index.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to apps/bubble-studio/public/bubbles.json : Refer to apps/bubble-studio/public/bubbles.json for a condensed definition of all bubbles (building/bundling is required)
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/index.tspackages/bubble-core/src/index.tspackages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Reference webhook.test as the example for how backend tests should be written
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.tsapps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.ts
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Use `pnpm bun test` command to run backend tests to ensure setup files are properly loaded
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-shared-schemas/src/bubbleflow-generation-prompts.ts : Refer to packages/bubble-shared-schemas/src/bubbleflow-generation-prompts.ts for documentation on how bubble flow is supposed to be generated
Applied to files:
packages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-core/CREATE_BUBBLE_README.md : Refer to packages/bubble-core/CREATE_BUBBLE_README.md for instructions on how to create bubbles
Applied to files:
packages/bubble-core/src/bubble-factory.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-runtime/src/extraction/README.md : Refer to packages/bubble-runtime/src/extraction/README.md for information about bubble parsing, dependency graphs, and per-invocation cloning
Applied to files:
packages/bubble-core/src/bubble-factory.ts
🧬 Code graph analysis (2)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.ts (3)
packages/bubble-core/src/bubbles/service-bubble/stripe/index.ts (1)
StripeBubble(1-1)packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (3)
StripeBubble(156-424)StripeParamsSchema(9-68)StripeResultSchema(120-151)packages/bubble-core/src/index.ts (1)
StripeBubble(50-50)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (1)
packages/bubble-core/src/types/bubble.ts (1)
BubbleContext(82-100)
🔇 Additional comments (24)
packages/bubble-shared-schemas/src/ai-models.ts (1)
13-13: LGTM! Remember to rebuild the schema package.The addition of 'google/gemini-1.5-flash' follows the existing pattern correctly.
As per coding guidelines, ensure you run
pnpm build:coreafter modifying shared schemas since it is a separate package and types need to be regenerated.packages/bubble-shared-schemas/src/credential-schema.ts (1)
34-34: LGTM! Remember to rebuild the schema package.The Stripe credential mappings are consistent and correctly follow the established pattern.
As per coding guidelines, ensure you run
pnpm build:coreafter modifying shared schemas since it is a separate package and types need to be regenerated.Also applies to: 376-376
packages/bubble-core/src/bubbles/service-bubble/stripe/index.ts (1)
1-1: LGTM!The re-export structure follows the established pattern for service bubbles correctly.
apps/bubblelab-api/src/services/credential-validator.ts (1)
198-200: LGTM!The Stripe credential test parameters with 'create_customer' operation are appropriate and follow the established pattern for minimal credential validation.
packages/bubble-shared-schemas/src/bubble-definition-schema.ts (1)
49-49: LGTM! Remember to rebuild after schema changes.The STRIPE_SECRET_KEY credential configuration follows the established pattern correctly.
As per coding guidelines, ensure you run
pnpm build:coreafter modifying shared schemas to regenerate types.packages/bubble-shared-schemas/src/types.ts (2)
48-50: LGTM!The STRIPE_SECRET_KEY credential type addition follows the established enum pattern correctly.
102-102: LGTM!The 'stripe' bubble name addition is consistent with the existing pattern.
packages/bubble-core/src/index.ts (2)
50-50: LGTM!StripeBubble export is correctly included as required by coding guidelines.
116-119: LGTM!The StripeParams and StripeResult type exports are correctly included and follow the established pattern for exposing public types.
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe-metadata-test-example.ts (1)
1-56: Test coverage for metadata looks good, but verify test file naming convention.The metadata tests are comprehensive and well-structured. However, the filename suffix "-metadata-test-example" is unusual. Standard test files typically use
.test.tsor.spec.tswithout "example" in the name.Verify whether this is intended as:
- An example/reference file (in which case, document it or move to docs)
- An actual test file (in which case, rename to follow standard convention like
stripe-metadata.test.ts)Also note that the next file (
stripe.test.ts) contains very similar test cases, which may indicate duplication.packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.test.ts (1)
1-34: Consolidate duplicate test files.This test file (
stripe.test.ts) contains nearly identical test cases tostripe-metadata-test-example.ts. Both files test:
- Static properties (bubbleName, service, authType, type, alias)
- shortDescription keywords
- longDescription keywords
- Schema validation
Having duplicate test files creates maintenance overhead and provides no additional coverage.
Recommended consolidation approach
Choose one of the following:
Option 1 (Recommended): Keep
stripe.test.tsand removestripe-metadata-test-example.ts
- The
.test.tssuffix follows standard conventions- The flatter structure is more concise
Option 2: Keep
stripe-metadata-test-example.tsbut rename it tostripe.test.ts
- Remove the current
stripe.test.ts- Rename to follow standard convention
- The nested describe structure provides better organization
Either way, maintain a single source of truth for metadata tests.
⛔ Skipped due to learnings
Learnt from: CR Repo: bubblelabai/BubbleLab PR: 0 File: .cursor/rules/api.mdc:0-0 Timestamp: 2025-12-19T03:16:48.801Z Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Reference webhook.test as the example for how backend tests should be writtenpackages/bubble-core/src/bubble-factory.ts (4)
161-161: LGTM!The 'stripe' entry is correctly added to the code generator bubble list, enabling Stripe in BubbleFlow code generation.
208-210: LGTM!The StripeBubble import follows the established pattern for other service bubbles.
330-330: LGTM!The Stripe bubble registration follows the existing pattern and is correctly placed alongside other service bubbles.
744-744: Model choice is supported but lacks documentation.The model
google/gemini-1.5-flashis present in the supported models list inpackages/bubble-shared-schemas/src/ai-models.ts, so there is no schema misalignment. However, this boilerplate template in bubble-factory.ts uses gemini-1.5-flash while the codebase predominantly uses gemini-2.5-flash elsewhere. If this downgrade is intentional for the template (e.g., for simpler/faster initialization), add a comment explaining the rationale.apps/bubble-studio/src/pages/CredentialsPage.tsx (2)
200-206: LGTM!The Stripe credential configuration follows the established pattern. The placeholder
sk_live_...correctly hints at the Stripe secret key format, and the description is clear and helpful.
309-309: LGTM!The service name mapping to 'Stripe' enables proper logo resolution in the UI.
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (7)
1-8: LGTM!The imports and base URL constant are correctly set up for Stripe API v1 integration.
9-68: LGTM!The
StripeParamsSchemadiscriminated union is well-structured with appropriate validation for each operation. The schema includes helpful descriptions for complex fields likeitems,collection_method, anddays_until_due.
70-151: LGTM!The result schemas are comprehensive and use
.passthrough()appropriately onSubscriptionResultSchemato allow additional Stripe response fields.
306-341: LGTM!The
createCustomermethod correctly constructs the request body and handles optional fields. The response mapping properly handles nullable email/name/description fields.
343-396: LGTM!The
createSubscriptionmethod correctly encodes array items in the form-urlencoded format expected by Stripe (items[0][price],items[0][quantity]). The use ofsafeParsefor response validation is a good practice.
398-423: LGTM!The
cancelSubscriptionmethod correctly uses the DELETE HTTP method and validates the response withsafeParse.
174-184: All required exports are already present.StripeBubble, StripeParams, and StripeResult are already exported from
packages/bubble-core/src/index.ts(lines 50, 117-119). No action needed.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
apps/bubblelab-api/src/services/credential-validator.ts (1)
60-60: Remove debug console.log statement before merging.This debug log statement appears to be leftover development code. Logging the bubble instance in production credential validation can leak sensitive information and adds unnecessary noise to logs.
🔎 Proposed fix
- console.log(bubbleInstance, ' Validating credential for bubble :'); - const serviceBubble = bubbleInstance as IServiceBubble;
🧹 Nitpick comments (1)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (1)
306-341: Consider using schema validation for consistency.The
createCustomermethod manually constructs the result object with type assertions (lines 324-340), whilecreateSubscriptionandcancelSubscriptionusesafeParsefor response validation. UsingCustomerResultSchema.safeParsewould provide more robust validation and consistency across all operations.🔎 Proposed refactor
const response = await this.makeStripeApiCall('POST', '/customers', body); + + let result: z.infer<typeof CustomerResultSchema> | undefined = undefined; + if (response.success && response.data) { + const parseResult = CustomerResultSchema.safeParse(response.data); + if (parseResult.success) { + result = parseResult.data; + } + } + return { operation: 'create_customer', - data: - response.success && response.data - ? { - id: (response.data as { id: string }).id, - email: - (response.data as { email?: string | null }).email ?? undefined, - name: - (response.data as { name?: string | null }).name ?? undefined, - description: - (response.data as { description?: string | null }) - .description ?? undefined, - created: (response.data as { created: number }).created, - } - : undefined, + data: result, error: response.success ? '' : response.error || 'Unknown Error', success: response.success, };
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/bubble-factory.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bubble-core/src/bubble-factory.ts
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: When adding new types to `bubblelab/shared-schemas`, they are automatically included in the bundle without requiring manual configuration changes
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Reference webhook.test as the example for how backend tests should be written
Applied to files:
apps/bubblelab-api/src/services/credential-validator.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-runtime/src/injection/README.md : Refer to packages/bubble-runtime/src/injection/README.md for information about credential injection and bubble parameter reinitialization
Applied to files:
apps/bubblelab-api/src/services/credential-validator.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/src/index.ts : All new types and classes added to bubble-core must be exported from `packages/bubble-core/src/index.ts` to ensure they are included in the generated bundle
Applied to files:
apps/bubblelab-api/src/services/credential-validator.tspackages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Use `pnpm bun test` command to run backend tests to ensure setup files are properly loaded
Applied to files:
apps/bubblelab-api/src/services/credential-validator.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/dist/**/*.d.ts : All external imports (except relative imports) must be removed from the bundled output to prevent circular processing and external dependency issues
Applied to files:
apps/bubblelab-api/src/services/credential-validator.ts
📚 Learning: 2025-12-22T09:55:47.873Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-shared-schemas/src/bubbleflow-generation-prompts.ts : Refer to packages/bubble-shared-schemas/src/bubbleflow-generation-prompts.ts for documentation on how bubble flow is supposed to be generated
Applied to files:
apps/bubblelab-api/src/services/credential-validator.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to packages/bubble-core/dist/**/*.d.ts : The type bundling system for Monaco Editor must process TypeScript declaration files (.d.ts) and inline all dependencies into a single self-contained bundle in `packages/bubble-core/dist/bubble-bundle.d.ts`
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
📚 Learning: 2025-12-19T03:17:06.825Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bundling.mdc:0-0
Timestamp: 2025-12-19T03:17:06.825Z
Learning: Applies to apps/bubble-studio/public/bubble-types.txt : The bundle file at `apps/bubble-studio/public/bubble-types.txt` must be kept synchronized with `packages/bubble-core/dist/bubble-bundle.d.ts` after each build
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/packages/bubble-shared-schemas/**/*.{ts,tsx} : Write shared schemas between frontend and backend in `/packages/bubble-shared-schemas` directory
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts
🔇 Additional comments (8)
apps/bubblelab-api/src/services/credential-validator.ts (1)
197-199: LGTM!The addition of
STRIPE_SECRET_KEYcredential type follows the established pattern for service bubble credential validation. Usingcreate_customeras the test operation is appropriate for validating Stripe credentials.packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.ts (7)
9-68: LGTM!The schema definition uses discriminated unions effectively for type-safe operation handling. Field validations are appropriate (email validation, minimum array length), and descriptions are helpful for API users.
70-151: LGTM!The result schemas are well-structured with a consistent pattern across operations. The use of
.passthrough()onSubscriptionResultSchema(line 118) appropriately allows Stripe's extensive response fields while validating required properties.
186-195: Constructor default parameters use type assertion.The default constructor parameters (lines 187-190) use a type assertion
as Tto cast thecreate_customeroperation to the generic typeT. While this could theoretically be unsafe ifTis constrained to a different operation, this pattern appears consistent with other service bubbles in the codebase.
162-173: LGTM!The credential test implementation correctly validates the API key with a minimal request (
/customers?limit=1) and returns the appropriate boolean result.
197-241: LGTM!Both
chooseCredentialandperformActionare implemented correctly. The operation routing uses a switch statement with proper type narrowing, and error handling ensures failed operations return structured error results.
246-304: LGTM!The
makeStripeApiCallhelper correctly implements Stripe's API requirements: form-urlencoded request body, Bearer token authentication, and proper error handling for both API errors (lines 281-290) and network failures (lines 299-303).
343-421: LGTM!Both
createSubscriptionandcancelSubscriptioncorrectly use schema validation (safeParse) to validate Stripe API responses before returning structured results. The implementation follows best practices for type-safe response handling.
|
@Ridhim-RR We have made a new guideline on testing for new bubble integration. could you add the three operations you showed in your screenshot as a bubbleflow file? Here is the new requirment: An integration flow test that exercises all operations end-to-end in realistic scenarios—including edge cases. This flow should be runnable in bubble studio and return structured results tracking each operation's success/failure with details. See Once thats ready we will test your end-to-end flow it a few time on our end and we can merge it in |
zhubzy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new required stripe.integration.flow.ts file
…at/stripe-integration-v1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
@packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.integration.flow.ts:
- Around line 29-34: The payload interface exposes an unused optional field
testPriceId2; update the code so it is consistent: either remove testPriceId2
from the interface if multi-item subscriptions are not supported, or modify the
handle() implementation (and any related test helpers) to include testPriceId2
when building the subscription payload so multi-item subscription tests actually
use both price IDs. Locate the payload/interface declaration and the handle()
method in stripe.integration.flow.ts and apply one of these fixes, ensuring any
test cases and types are updated accordingly.
🧹 Nitpick comments (3)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.integration.flow.ts (3)
45-51: Consider improving error message fallback.If
result.successis false butresult.erroris undefined, the error message will read "Failed to create customer: undefined". A fallback would improve debuggability.♻️ Suggested improvement
if ( !result.success || result.data?.operation !== 'create_customer' || !result.data?.data ) { - throw new Error(`Failed to create customer: ${result.error}`); + throw new Error(`Failed to create customer: ${result.error ?? 'Unknown error'}`); }
74-87: Consider using shorthand property syntax.Minor style nit:
subscriptionId: subscriptionIdcan be simplified.♻️ Suggested improvement
private async cancelTestSubscription(subscriptionId: string) { const result = await new StripeBubble({ operation: 'cancel_subscription', - subscriptionId: subscriptionId, + subscriptionId, }).action();
89-127: Test failures are thrown rather than recorded intestResults.The
testResultsarray only captures successful operations. When an exception occurs, the failure isn't recorded in the output—the flow simply throws. This is acceptable for fail-fast testing, but consider whether recording failures intestResultswithsuccess: falsewould provide better diagnostics, especially for integration test runs where you want a structured report of what failed.Additionally, if subscription creation fails after customer creation, the test customer remains in Stripe. For a stress test that may run repeatedly, consider whether cleanup of partial state is needed.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.integration.flow.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/bubblelab.mdc:0-0
Timestamp: 2025-12-22T09:55:47.873Z
Learning: Applies to packages/bubble-runtime/src/injection/README.md : Refer to packages/bubble-runtime/src/injection/README.md for information about credential injection and bubble parameter reinitialization
📚 Learning: 2025-12-19T03:16:48.801Z
Learnt from: CR
Repo: bubblelabai/BubbleLab PR: 0
File: .cursor/rules/api.mdc:0-0
Timestamp: 2025-12-19T03:16:48.801Z
Learning: Applies to **/bubblelab-api/**/*.test.{js,ts} : Reference webhook.test as the example for how backend tests should be written
Applied to files:
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.integration.flow.ts
🔇 Additional comments (1)
packages/bubble-core/src/bubbles/service-bubble/stripe/stripe.integration.flow.ts (1)
1-15: LGTM!Imports are minimal and appropriate. The
Outputinterface provides a well-structured contract for test results with proper tracking of customer, subscriptions, and per-operation success/failure details.
Summary
This PR adds full Stripe integration to BubbleLab, enabling users to create customers, create and cancel subscriptions, through the Stripe API. The integration follows the standard ServiceBubble pattern with proper credential injection, schema validation, and error handling.
Related Issues
Fixes #249
Type of Change
Checklist
pnpm checkand all tests passScreenshots (if applicable)
Additional Context
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.