Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Aug 14, 2025

Resolves #17991

Summary by CodeRabbit

  • New Features
    • Added Stripe action to cancel subscriptions directly from the app, with a clear success summary.
    • Added Stripe action to search subscriptions using a flexible query and optional result limit, with automatic pagination and summarized results.
  • Chores
    • Bumped Stripe component version to 0.8.0.

@vercel
Copy link

vercel bot commented Aug 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored Preview Aug 14, 2025 3:49pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored Aug 14, 2025 3:49pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
New Action: Cancel Subscription
components/stripe/actions/cancel-subscription/cancel-subscription.mjs
Introduces an action to cancel a Stripe subscription via subscriptions.cancel(subscriptionId), exporting a summary and returning the API response.
New Action: Search Subscriptions
components/stripe/actions/search-subscriptions/search-subscriptions.mjs
Adds an action to search subscriptions using Stripe’s search API with pagination, respecting maxResults, and exporting a summary of retrieved count.
Package Version
components/stripe/package.json
Increments version from 0.7.2 to 0.8.0.

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)
Loading
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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Implement Stripe action to cancel subscriptions (#17991)
Implement Stripe action to search subscriptions (#17991)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Version bump to 0.8.0 (components/stripe/package.json) Related to releasing new actions; not out of scope.

Poem

I twitch my ears at version eight-oh,
Two Stripe tricks ready to go—
Search the burrow, cancel the warren,
Hop through pages, no need for sorrow.
Thump! A summary, neat and tight—
Carrot-powered APIs, working right. 🥕✨

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-17991

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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.

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 summary

Forwarding 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: Validate maxResults to avoid unnecessary API calls on non-positive values

Add 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 maxResults

Avoid 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 results

Lower 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 readability

Small 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5d27ebe and 7881f99.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 — LGTM

Minor 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 exposes subscription propDefinition and sdk() 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 — LGTM

Use of subscriptions.search with has_more and next_page matches Stripe’s search pagination model. Early break when data is empty is a good guard.

@vunguyenhung vunguyenhung merged commit 84db822 into master Aug 15, 2025
11 checks passed
@vunguyenhung vunguyenhung deleted the issue-17991 branch August 15, 2025 00:38
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.

[ACTION] Stripe - Expanded Actions

4 participants