Skip to content

[FEATURE] Upgrade Pipedream Stripe App to Latest Stable API Version #16463

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "stripe-cancel-or-reverse-payout",
name: "Cancel Or Reverse a Payout",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Cancel or reverse a [payout](https://stripe.com/docs/payouts). " +
"A payout can be canceled only if it has not yet been paid out. A payout can be reversed " +
"only if it has already been paid out. Funds will be refunded to your available balance. [See" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "stripe-cancel-payment-intent",
name: "Cancel a Payment Intent",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Cancel a [payment intent](https://stripe.com/docs/payments/payment-intents). " +
"Once canceled, no additional charges will be made by the payment intent and any operations " +
"on the payment intent will fail with an error. For payment intents with status=" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import app from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-capture-payment-intent",
name: "Capture a Payment Intent",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Capture the funds of an existing uncaptured payment intent. [See the " +
"docs](https://stripe.com/docs/api/payment_intents/capture) for more information",
props: {
Expand Down Expand Up @@ -42,7 +43,7 @@ export default {
]);
const resp = await this.app.sdk().paymentIntents.capture(this.id, {
...params,
...this.advanced,
...utils.parseJson(this.advanced),
});
$.export("$summary", `Successfully captured ${params.amount_to_capture
? params.amount_to_capture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import app from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-confirm-payment-intent",
name: "Confirm a Payment Intent",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Confirm that your customer intends to pay with current or provided payment " +
"method. Upon confirmation, Stripe will attempt to initiate a payment. [See the " +
"docs](https://stripe.com/docs/api/payment_intents/confirm) for more information",
Expand Down Expand Up @@ -65,7 +66,7 @@ export default {
]);
const resp = await this.app.sdk().paymentIntents.confirm(this.id, {
...params,
...this.advanced,
...utils.parseJson(this.advanced),
});
$.export("$summary", "Successfully confirmed the payment intent");
return resp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import app from "../../stripe.app.mjs";

export default {
key: "stripe-create-billing-meter",
name: "Create Billing Meter",
type: "action",
version: "0.0.1",
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).",
props: {
app,
defaultAggregationFormula: {
type: "string",
label: "Default Aggregation Formula",
description: "Specifies how events are aggregated",
options: [
{
label: "Count the number of events",
value: "count",
},
{
label: "Take the last event's value in the window",
value: "last",
},
{
label: "Sum each event's value",
value: "sum",
},
],
},
displayName: {
type: "string",
label: "Display Name",
description: "The meter's name. Not visible to the customer.",
},
eventName: {
type: "string",
label: "Event Name",
description: "The name of the meter event to record usage for. Corresponds with the `event_name` field on meter events.",
},
customerMappingEventPayloadKey: {
type: "string",
label: "Customer Mapping Event Payload Key",
description: "The key in the meter event payload to use for mapping the event to a customer.",
optional: true,
},
eventTimeWindow: {
type: "string",
label: "Event Time Window",
description: "The time window to pre-aggregate meter events for, if any.",
optional: true,
options: [
{
label: "Events are pre-aggregated in daily buckets",
value: "day",
},
{
label: "Events are pre-aggregated in hourly buckets",
value: "hour",
},
],
},
valueSettingsEventPayloadKey: {
type: "string",
label: "Value Settings Event Payload Key",
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`.",
optional: true,
},
},
async run({ $ }) {
const {
defaultAggregationFormula,
displayName,
eventName,
customerMappingEventPayloadKey,
eventTimeWindow,
valueSettingsEventPayloadKey,
} = this;

const response = await this.app.sdk().billing.meters.create({
default_aggregation: {
formula: defaultAggregationFormula,
},
display_name: displayName,
event_name: eventName,
...(customerMappingEventPayloadKey && {
customer_mapping: {
event_payload_key: customerMappingEventPayloadKey,
type: "by_id",
},
}),
event_time_window: eventTimeWindow,
...(valueSettingsEventPayloadKey && {
value_settings: {
event_payload_key: valueSettingsEventPayloadKey,
},
}),
});

$.export("$summary", `Successfully created a new billing meter with ID \`${response.id}\``);
return response;
},
};
5 changes: 3 additions & 2 deletions components/stripe/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import app from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-create-customer",
name: "Create a Customer",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Create a customer. [See the docs](https://stripe.com/docs/api/customers/create) " +
"for more information",
props: {
Expand Down Expand Up @@ -105,7 +106,7 @@ export default {
const resp = await this.app.sdk().customers.create({
...params,
address,
...this.advanced,
...utils.parseJson(this.advanced),
});
$.export("$summary", `Successfully created a new customer, "${resp.id}"`);
return resp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import app from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-create-invoice-item",
name: "Create Invoice Line Item",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Add a line item to an invoice. [See the " +
"docs](https://stripe.com/docs/api/invoiceitems/create) for more information",
props: {
Expand Down Expand Up @@ -84,10 +85,14 @@ export default {
},
},
async run({ $ }) {
const resp = await this.app.sdk().invoiceItems.create({
const {
app,
price,
advanced,
} = this;
const resp = await app.sdk().invoiceItems.create({
...pick(this, [
"customer",
"price",
"subscription",
"invoice",
"amount",
Expand All @@ -96,7 +101,15 @@ export default {
"description",
"metadata",
]),
...this.advanced,
...(price
? {
pricing: {
price,
},
}
: {}
),
...utils.parseJson(advanced),
});

$.export("$summary", "Successfully added new invoice item");
Expand Down
5 changes: 3 additions & 2 deletions components/stripe/actions/create-invoice/create-invoice.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import app from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-create-invoice",
name: "Create Invoice",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Create an invoice. [See the docs](https://stripe.com/docs/api/invoices/create) " +
"for more information",
props: {
Expand Down Expand Up @@ -92,7 +93,7 @@ export default {
"default_payment_method",
"metadata",
]),
...this.advanced,
...utils.parseJson(this.advanced),
});

$.export("$summary", "Successfully created a new invoice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "stripe-create-payment-intent",
name: "Create a Payment Intent",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Create a [payment intent](https://stripe.com/docs/payments/payment-intents). [See" +
"the docs](https://stripe.com/docs/api/payment_intents/create) for more information",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/stripe/actions/create-payout/create-payout.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "stripe-create-payout",
name: "Create a Payout",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Send funds to your own bank account. Your Stripe balance must be able to cover " +
"the payout amount, or you'll receive an 'Insufficient Funds' error. [See the " +
"docs](https://stripe.com/docs/api/payouts/create) for more information",
Expand Down
2 changes: 1 addition & 1 deletion components/stripe/actions/create-price/create-price.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "stripe-create-price",
name: "Create Price",
description: "Creates a new price for an existing product. The price can be recurring or one-time. [See the documentation](https://stripe.com/docs/api/prices/create)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "stripe-create-product",
name: "Create Product",
description: "Creates a new product object in Stripe. [See the documentation](https://stripe.com/docs/api/products/create)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
2 changes: 1 addition & 1 deletion components/stripe/actions/create-refund/create-refund.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "stripe-create-refund",
name: "Create a Refund",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Creating a new refund will refund a charge that has previously been created but " +
"not yet refunded. Funds will be refunded to the credit or debit card that was originally " +
"charged. You can optionally refund only part of a charge. You can do so multiple times, " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pick from "lodash.pick";
import stripe from "../../stripe.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "stripe-create-subscription",
name: "Create Subscription",
type: "action",
version: "0.1.1",
version: "0.1.2",
description: "Create a subscription. [See docs here](https://stripe.com/docs/api/subscriptions/create)",
props: {
stripe,
Expand Down Expand Up @@ -89,6 +90,14 @@ export default {
"metadata",
],
},
advanced: {
label: "Advanced Options",
description: "Add any additional parameters that you require here",
propDefinition: [
stripe,
"metadata",
],
},
},
async run({ $ }) {
const items = typeof this.items === "string"
Expand All @@ -108,6 +117,7 @@ export default {
items: items.map((item) => ({
price: item,
})),
...utils.parseJson(this.advanced),
});

$.export("$summary", `Successfully created a new subscription with id ${resp.id}`);
Expand Down
Loading