Skip to content

Commit 8c41a71

Browse files
committed
[FEATURE] Upgrade Pipedream Stripe App to Latest Stable API Version
1 parent aae9f1c commit 8c41a71

File tree

60 files changed

+638
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+638
-214
lines changed

components/stripe/actions/cancel-or-reverse-payout/cancel-or-reverse-payout.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "stripe-cancel-or-reverse-payout",
55
name: "Cancel Or Reverse a Payout",
66
type: "action",
7-
version: "0.1.1",
7+
version: "0.1.2",
88
description: "Cancel or reverse a [payout](https://stripe.com/docs/payouts). " +
99
"A payout can be canceled only if it has not yet been paid out. A payout can be reversed " +
1010
"only if it has already been paid out. Funds will be refunded to your available balance. [See" +

components/stripe/actions/cancel-payment-intent/cancel-payment-intent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "stripe-cancel-payment-intent",
66
name: "Cancel a Payment Intent",
77
type: "action",
8-
version: "0.1.1",
8+
version: "0.1.2",
99
description: "Cancel a [payment intent](https://stripe.com/docs/payments/payment-intents). " +
1010
"Once canceled, no additional charges will be made by the payment intent and any operations " +
1111
"on the payment intent will fail with an error. For payment intents with status=" +

components/stripe/actions/capture-payment-intent/capture-payment-intent.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pick from "lodash.pick";
22
import app from "../../stripe.app.mjs";
3+
import utils from "../../common/utils.mjs";
34

45
export default {
56
key: "stripe-capture-payment-intent",
67
name: "Capture a Payment Intent",
78
type: "action",
8-
version: "0.1.1",
9+
version: "0.1.2",
910
description: "Capture the funds of an existing uncaptured payment intent. [See the " +
1011
"docs](https://stripe.com/docs/api/payment_intents/capture) for more information",
1112
props: {
@@ -42,7 +43,7 @@ export default {
4243
]);
4344
const resp = await this.app.sdk().paymentIntents.capture(this.id, {
4445
...params,
45-
...this.advanced,
46+
...utils.parseJson(this.advanced),
4647
});
4748
$.export("$summary", `Successfully captured ${params.amount_to_capture
4849
? params.amount_to_capture

components/stripe/actions/confirm-payment-intent/confirm-payment-intent.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pick from "lodash.pick";
22
import app from "../../stripe.app.mjs";
3+
import utils from "../../common/utils.mjs";
34

45
export default {
56
key: "stripe-confirm-payment-intent",
67
name: "Confirm a Payment Intent",
78
type: "action",
8-
version: "0.1.1",
9+
version: "0.1.2",
910
description: "Confirm that your customer intends to pay with current or provided payment " +
1011
"method. Upon confirmation, Stripe will attempt to initiate a payment. [See the " +
1112
"docs](https://stripe.com/docs/api/payment_intents/confirm) for more information",
@@ -65,7 +66,7 @@ export default {
6566
]);
6667
const resp = await this.app.sdk().paymentIntents.confirm(this.id, {
6768
...params,
68-
...this.advanced,
69+
...utils.parseJson(this.advanced),
6970
});
7071
$.export("$summary", "Successfully confirmed the payment intent");
7172
return resp;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import app from "../../stripe.app.mjs";
2+
3+
export default {
4+
key: "stripe-create-billing-meter",
5+
name: "Create Billing Meter",
6+
type: "action",
7+
version: "0.0.1",
8+
description: "Meters specify how to aggregate meter events over a billing period. Meter events represent all actions that customers take in your system (for example, API requests). Meters attach to prices and form the basis of what's billed. [See the documentation](https://docs.stripe.com/api/billing/meter/create).",
9+
props: {
10+
app,
11+
defaultAggregationFormula: {
12+
type: "string",
13+
label: "Default Aggregation Formula",
14+
description: "Specifies how events are aggregated",
15+
options: [
16+
{
17+
label: "Count the number of events",
18+
value: "count",
19+
},
20+
{
21+
label: "Take the last event's value in the window",
22+
value: "last",
23+
},
24+
{
25+
label: "Sum each event's value",
26+
value: "sum",
27+
},
28+
],
29+
},
30+
displayName: {
31+
type: "string",
32+
label: "Display Name",
33+
description: "The meter's name. Not visible to the customer.",
34+
},
35+
eventName: {
36+
type: "string",
37+
label: "Event Name",
38+
description: "The name of the meter event to record usage for. Corresponds with the `event_name` field on meter events.",
39+
},
40+
customerMappingEventPayloadKey: {
41+
type: "string",
42+
label: "Customer Mapping Event Payload Key",
43+
description: "The key in the meter event payload to use for mapping the event to a customer.",
44+
optional: true,
45+
},
46+
eventTimeWindow: {
47+
type: "string",
48+
label: "Event Time Window",
49+
description: "The time window to pre-aggregate meter events for, if any.",
50+
optional: true,
51+
options: [
52+
{
53+
label: "Events are pre-aggregated in daily buckets",
54+
value: "day",
55+
},
56+
{
57+
label: "Events are pre-aggregated in hourly buckets",
58+
value: "hour",
59+
},
60+
],
61+
},
62+
valueSettingsEventPayloadKey: {
63+
type: "string",
64+
label: "Value Settings Event Payload Key",
65+
description: "The key in the usage event payload to use as the value for this meter. For example, if the event payload contains usage on a `bytes_used` field, then set it to `bytes_used`.",
66+
optional: true,
67+
},
68+
},
69+
async run({ $ }) {
70+
const {
71+
defaultAggregationFormula,
72+
displayName,
73+
eventName,
74+
customerMappingEventPayloadKey,
75+
eventTimeWindow,
76+
valueSettingsEventPayloadKey,
77+
} = this;
78+
79+
const response = await this.app.sdk().billing.meters.create({
80+
default_aggregation: {
81+
formula: defaultAggregationFormula,
82+
},
83+
display_name: displayName,
84+
event_name: eventName,
85+
...(customerMappingEventPayloadKey && {
86+
customer_mapping: {
87+
event_payload_key: customerMappingEventPayloadKey,
88+
type: "by_id",
89+
},
90+
}),
91+
event_time_window: eventTimeWindow,
92+
...(valueSettingsEventPayloadKey && {
93+
value_settings: {
94+
event_payload_key: valueSettingsEventPayloadKey,
95+
},
96+
}),
97+
});
98+
99+
$.export("$summary", `Successfully created a new billing meter with ID \`${response.id}\``);
100+
return response;
101+
},
102+
};

components/stripe/actions/create-customer/create-customer.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pick from "lodash.pick";
22
import app from "../../stripe.app.mjs";
3+
import utils from "../../common/utils.mjs";
34

45
export default {
56
key: "stripe-create-customer",
67
name: "Create a Customer",
78
type: "action",
8-
version: "0.1.1",
9+
version: "0.1.2",
910
description: "Create a customer. [See the docs](https://stripe.com/docs/api/customers/create) " +
1011
"for more information",
1112
props: {
@@ -105,7 +106,7 @@ export default {
105106
const resp = await this.app.sdk().customers.create({
106107
...params,
107108
address,
108-
...this.advanced,
109+
...utils.parseJson(this.advanced),
109110
});
110111
$.export("$summary", `Successfully created a new customer, "${resp.id}"`);
111112
return resp;

components/stripe/actions/create-invoice-item/create-invoice-item.mjs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pick from "lodash.pick";
22
import app from "../../stripe.app.mjs";
3+
import utils from "../../common/utils.mjs";
34

45
export default {
56
key: "stripe-create-invoice-item",
67
name: "Create Invoice Line Item",
78
type: "action",
8-
version: "0.1.1",
9+
version: "0.1.2",
910
description: "Add a line item to an invoice. [See the " +
1011
"docs](https://stripe.com/docs/api/invoiceitems/create) for more information",
1112
props: {
@@ -84,10 +85,14 @@ export default {
8485
},
8586
},
8687
async run({ $ }) {
87-
const resp = await this.app.sdk().invoiceItems.create({
88+
const {
89+
app,
90+
price,
91+
advanced,
92+
} = this;
93+
const resp = await app.sdk().invoiceItems.create({
8894
...pick(this, [
8995
"customer",
90-
"price",
9196
"subscription",
9297
"invoice",
9398
"amount",
@@ -96,7 +101,15 @@ export default {
96101
"description",
97102
"metadata",
98103
]),
99-
...this.advanced,
104+
...(price
105+
? {
106+
pricing: {
107+
price,
108+
},
109+
}
110+
: {}
111+
),
112+
...utils.parseJson(advanced),
100113
});
101114

102115
$.export("$summary", "Successfully added new invoice item");

components/stripe/actions/create-invoice/create-invoice.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pick from "lodash.pick";
22
import app from "../../stripe.app.mjs";
3+
import utils from "../../common/utils.mjs";
34

45
export default {
56
key: "stripe-create-invoice",
67
name: "Create Invoice",
78
type: "action",
8-
version: "0.1.1",
9+
version: "0.1.2",
910
description: "Create an invoice. [See the docs](https://stripe.com/docs/api/invoices/create) " +
1011
"for more information",
1112
props: {
@@ -92,7 +93,7 @@ export default {
9293
"default_payment_method",
9394
"metadata",
9495
]),
95-
...this.advanced,
96+
...utils.parseJson(this.advanced),
9697
});
9798

9899
$.export("$summary", "Successfully created a new invoice");

components/stripe/actions/create-payment-intent/create-payment-intent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "stripe-create-payment-intent",
66
name: "Create a Payment Intent",
77
type: "action",
8-
version: "0.1.1",
8+
version: "0.1.2",
99
description: "Create a [payment intent](https://stripe.com/docs/payments/payment-intents). [See" +
1010
"the docs](https://stripe.com/docs/api/payment_intents/create) for more information",
1111
props: {

components/stripe/actions/create-payout/create-payout.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "stripe-create-payout",
66
name: "Create a Payout",
77
type: "action",
8-
version: "0.1.1",
8+
version: "0.1.2",
99
description: "Send funds to your own bank account. Your Stripe balance must be able to cover " +
1010
"the payout amount, or you'll receive an 'Insufficient Funds' error. [See the " +
1111
"docs](https://stripe.com/docs/api/payouts/create) for more information",

0 commit comments

Comments
 (0)