To create a customer and an invoice with line items in Stripe, you can use the pre-built Stripe actions in Pipedream. Here’s how to do it: 1. Search for the Stripe app from the step menu and select the “Create Customer” action. Connect your Stripe account and configure the required fields. 2. To create an invoice line item, search for the Stripe app from the step menu again and select the “Create Invoice Line Item” action. Connect your Stripe account and configure the required fields, including the Customer ID from the previous step. 3. Finally, to create the invoice, search for the Stripe app from the step menu once more and select the “Create Invoice” action. Connect your Stripe account and configure the required fields, including the Customer ID from the first step. Remember to visit https://pipedream.com/pricing for the latest pricing information.
To achieve this, you can use the Google Sheets app in Pipedream and create a custom code step to perform the calculations. Here’s a step-by-step guide: 1. Search for the Google Sheets app from the step menu and select the “Get Sheet Values” action. Connect your Google Sheets account and configure the required fields, such as the Spreadsheet ID and the Range (e.g., “Sheet1!H1:AC100” for columns H-AC and rows 1-100). 2. Add a custom code step to calculate the total items and multiply it by the price. Here’s an example code snippet: export default defineComponent({ props: { items: { type: "string[]", label: "Items", }, price: { type: "integer", label: "Price", }, }, async run({ steps }) { const itemsArray = steps.get_sheet_values.values; let totalItems = 0; for (const row of itemsArray) { for (const item of row) { totalItems += parseInt(item, 10); } } const totalPrice = totalItems * this.price; return { totalItems, totalPrice }; }, }); In this code snippet, replace steps.get_sheet_values.values with the actual step reference from the “Get Sheet Values” action. Make sure to configure the items and price props as needed. This custom code step will return the total items and the total price based on the provided price.
I understand that you want to sum the values in the array and get a whole number. You can achieve this by adding a custom code step after the “Get Sheet Values” step. Here’s an example code snippet: export default defineComponent({ async run({ steps }) { const rowValues = steps.get_sheet_values.values[0]; let total = 0; for (const value of rowValues) { total += parseInt(value, 10); } return { total }; }, }); Replace steps.get_sheet_values.values with the actual step reference from the “Get Sheet Values” action. This custom code step will sum the values in the array and return the total as a whole number.
export default defineComponent({
async run({ steps }) {
const rowValues = steps.get_sheet_values.values[0];
let total = 0;
for (const value of rowValues) {
total += parseInt(value, 10);
}
return { total };
},
});
I would like a FIELD where I can put the VALUE.
This code does not add up the ARRAY.
Let’s say this is the ARRAY:
I apologize for the confusion. I’ve made adjustments to the code to include a field for the value and to correctly sum the array values. export default defineComponent({ props: { value: { type: "integer", label: "Value", }, }, async run({ steps }) { const rowValues = steps.get_sheet_values.values[0]; let total = 0; for (const value of rowValues) { total += Number(value); } return { total }; }, }); In this updated code, I’ve added a value prop to allow you to input a value. Additionally, I’ve changed parseInt(value, 10) to Number(value) to correctly sum the array values.
I apologize for the confusion earlier. Based on the array you provided, let’s modify the custom code step to correctly sum the values: export default defineComponent({ async run({ steps }) { const rowValues = steps.get_values_in_range.$return_value[0]; let total = 0; for (const value of rowValues) { total += Number(value); } return { total }; }, }); In this updated code, I’ve changed the reference to steps.get_values_in_range.$return_value[0] to correctly access the array. This should now sum the values in the array and return the correct total.
export default defineComponent({
async run({ steps }) {
const rowValues = steps.get_values_in_range.$return_value[0];
let total = 0;
for (const value of rowValues) {
total += Number(value);
}
return { total };
},
});
I apologize for the oversight. Here’s the updated code with the input field for the value: export default defineComponent({ props: { values: { type: "string[]", label: "Values", }, }, async run({ steps }) { const rowValues = this.values || steps.get_values_in_range.$return_value[0]; let total = 0; for (const value of rowValues) { total += Number(value); } return { total }; }, }); In this updated code, I’ve added a values prop that accepts an array of strings. You can input the values in the Pipedream UI by using this field. If the values prop is not provided, it will fall back to using the steps.get_values_in_range.$return_value[0].