Skip to content

Commit 84db822

Browse files
authored
Merging pull request #18060
* new components * pnpm-lock.yaml
1 parent a758b23 commit 84db822

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import stripe from "../../stripe.app.mjs";
2+
3+
export default {
4+
key: "stripe-cancel-subscription",
5+
name: "Cancel Subscription",
6+
description: "Cancel a subscription. [See the documentation](https://docs.stripe.com/api/subscriptions/cancel?lang=node)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
stripe,
11+
subscriptionId: {
12+
propDefinition: [
13+
stripe,
14+
"subscription",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.stripe.sdk().subscriptions.cancel(this.subscriptionId);
20+
21+
$.export("$summary", `Cancelled subscription ${this.subscriptionId}`);
22+
23+
return response;
24+
},
25+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import stripe from "../../stripe.app.mjs";
2+
3+
export default {
4+
key: "stripe-search-subscriptions",
5+
name: "Search Subscriptions",
6+
description: "Search for subscriptions. [See the documentation](https://docs.stripe.com/api/subscriptions/search?lang=node)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
stripe,
11+
query: {
12+
type: "string",
13+
label: "Query",
14+
description: "The search query string. See [search query language](https://docs.stripe.com/search#search-query-language) and the list of supported [query fields for subscriptions](https://docs.stripe.com/search#query-fields-for-subscriptions).",
15+
},
16+
maxResults: {
17+
type: "integer",
18+
label: "Max Results",
19+
description: "The maximum number of results to return",
20+
default: 100,
21+
optional: true,
22+
},
23+
},
24+
async run({ $ }) {
25+
const params = {
26+
query: this.query,
27+
limit: 100,
28+
};
29+
let hasMore, count = 0;
30+
31+
const results = [];
32+
do {
33+
const response = await this.stripe.sdk().subscriptions.search(params);
34+
if (!response?.data?.length) {
35+
break;
36+
}
37+
for (const subscription of response.data) {
38+
results.push(subscription);
39+
count++;
40+
if (count >= this.maxResults) {
41+
break;
42+
}
43+
}
44+
hasMore = response.has_more;
45+
params.page = response.next_page;
46+
} while (hasMore && count < this.maxResults);
47+
48+
$.export("$summary", `Retrieved ${results.length} subscriptions`);
49+
50+
return results;
51+
},
52+
};

components/stripe/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/stripe",
3-
"version": "0.7.2",
3+
"version": "0.8.0",
44
"description": "Pipedream Stripe Components",
55
"main": "stripe.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)