-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - stripe #18060
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
New Components - stripe #18060
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
WalkthroughAdds two new Stripe action modules to cancel a subscription and search subscriptions, and bumps the Stripe components package version from 0.7.2 to 0.8.0. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CancelAction
participant StripeAPI
User->>CancelAction: Trigger with subscriptionId
CancelAction->>StripeAPI: subscriptions.cancel(subscriptionId)
StripeAPI-->>CancelAction: Cancellation response
CancelAction-->>User: Return response (+$summary)
sequenceDiagram
participant User
participant SearchAction
participant StripeAPI
User->>SearchAction: Trigger with query, maxResults
loop paginate until maxResults or no more
SearchAction->>StripeAPI: subscriptions.search({query, limit:100, page})
StripeAPI-->>SearchAction: {data[], has_more, next_page}
SearchAction->>SearchAction: accumulate results
end
SearchAction-->>User: Return results (+$summary)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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
🧹 Nitpick comments (6)
components/stripe/actions/cancel-subscription/cancel-subscription.mjs (2)
9-17: Surface optional cancel parameters to users (invoice_now, prorate, additional fields)Exposing common cancel parameters improves usability and parity with Stripe’s Cancel API. Recommend adding props for invoice_now, prorate, and a generic additionalFields object for advanced use (e.g., cancellation_details).
Apply this diff to extend the props:
props: { stripe, subscriptionId: { propDefinition: [ stripe, "subscription", ], }, + invoiceNow: { + type: "boolean", + label: "Invoice Now", + description: "If true, invoice the latest pending usage immediately upon cancellation.", + optional: true, + }, + prorate: { + type: "boolean", + label: "Prorate", + description: "If true, apply proration when canceling.", + optional: true, + }, + additionalFields: { + type: "object", + label: "Additional Fields", + description: "Any additional parameters to pass to the Stripe API (e.g., { cancellation_details: { feedback: 'other', comment: 'Reason' } }).", + optional: true, + }, },
18-24: Pass cancel options to Stripe and enrich the action summaryForwarding optional params enables common Stripe behaviors without custom code. Enriching $summary with status and canceled_at provides better UX.
Apply this diff:
- async run({ $ }) { - const response = await this.stripe.sdk().subscriptions.cancel(this.subscriptionId); - - $.export("$summary", `Cancelled subscription ${this.subscriptionId}`); - - return response; - }, + async run({ $ }) { + const params = { + ...(this.additionalFields || {}), + }; + if (this.invoiceNow !== undefined) params.invoice_now = this.invoiceNow; + if (this.prorate !== undefined) params.prorate = this.prorate; + + const response = await this.stripe.sdk().subscriptions.cancel(this.subscriptionId, params); + + const status = response?.status; + const canceledAt = response?.canceled_at + ? new Date(response.canceled_at * 1000).toISOString() + : undefined; + + $.export("$summary", `Cancelled subscription ${response?.id ?? this.subscriptionId}${status ? ` (status: ${status}${canceledAt ? `, canceled_at: ${canceledAt}` : ""})` : ""}`); + + return response; + },components/stripe/actions/search-subscriptions/search-subscriptions.mjs (4)
16-22: ValidatemaxResultsto avoid unnecessary API calls on non-positive valuesAdd a minimum constraint so users don’t accidentally trigger a call when they intend to fetch zero items.
Apply this diff:
maxResults: { type: "integer", label: "Max Results", description: "The maximum number of results to return", default: 100, optional: true, + min: 1, },
25-28: Right-size the per-page limit based on maxResultsAvoid fetching more than necessary on the first page by capping the limit to the requested total.
Apply this diff:
- const params = { - query: this.query, - limit: 100, - }; + const perPage = Math.min(100, this.maxResults ?? 100); + const params = { + query: this.query, + limit: perPage, + };
44-46: Tighten subsequent page requests to remaining resultsLower the per-page limit as you approach maxResults to minimize over-fetch.
Apply this diff:
- hasMore = response.has_more; - params.page = response.next_page; + hasMore = response.has_more; + params.page = response.next_page; + // Reduce per-page limit for the next request if we’re close to maxResults + params.limit = Math.min(100, this.maxResults - count);
48-48: Minor: pluralize summary for better readabilitySmall UX improvement to the run summary.
Apply this diff:
- $.export("$summary", `Retrieved ${results.length} subscriptions`); + $.export("$summary", `Retrieved ${results.length} subscription${results.length === 1 ? "" : "s"}`);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these settings in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
components/stripe/actions/cancel-subscription/cancel-subscription.mjs(1 hunks)components/stripe/actions/search-subscriptions/search-subscriptions.mjs(1 hunks)components/stripe/package.json(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
components/stripe/actions/cancel-subscription/cancel-subscription.mjs (1)
components/stripe/actions/search-subscriptions/search-subscriptions.mjs (1)
response(33-33)
components/stripe/actions/search-subscriptions/search-subscriptions.mjs (1)
components/stripe/actions/cancel-subscription/cancel-subscription.mjs (1)
response(19-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
🔇 Additional comments (3)
components/stripe/package.json (1)
3-3: Version bump aligns with added actions — LGTMMinor version bump to 0.8.0 matches the addition of new actions. No other package-level changes needed from what's shown.
components/stripe/actions/cancel-subscription/cancel-subscription.mjs (1)
11-16: Confirmed — Stripe app exposessubscriptionpropDefinition andsdk()helper; no change required
- components/stripe/stripe.app.mjs — propDefinitions.subscription present (around lines 181–184).
- components/stripe/stripe.app.mjs — sdk() helper defined (around line 606).
- components/stripe/actions/cancel-subscription/cancel-subscription.mjs — calls this.stripe.sdk().subscriptions.cancel(this.subscriptionId) (line ~19).
components/stripe/actions/search-subscriptions/search-subscriptions.mjs (1)
33-46: Overall pagination flow looks correct — LGTMUse of
subscriptions.searchwithhas_moreandnext_pagematches Stripe’s search pagination model. Early break when data is empty is a good guard.
Resolves #17991
Summary by CodeRabbit