This topic was automatically generated from Slack. You can find the original thread here.
Just a quick question, how do you import Stripe in this case?
This topic was automatically generated from Slack. You can find the original thread here.
Just a quick question, how do you import Stripe in this case?
Hi Nans,
Good question, I actually came across this myself.
Here’s the way I handled it:
import stripe from 'stripe'
export default defineComponent({
props: {
stripe: {
type: "app",
app: "stripe",
},
},
async run({steps, $}) {
const client = stripe(this.stripe.$auth.api_key)
return await client.subscriptions.create({ your payload here...})
},
})
Thx for your quick response!
Almost
I believe the bug is within your call.
Per the Stripe docs, the signature for that method is client.subscriptions.create
not client.subscription.create
All resources are pluralized in Stripe
Yes, well done! Since I copied and pasted your code just above, I got caught Thanks!
Ah that explains it. I hallucinated the method
I’ve just updated the Stripe Node.js scaffolding to use the Stripe Node SDK instead of axios, so you should get this structure out of the box now. Let me know if you have any issues with it!
I take advantage of having reactivity in the thread. I’m new to Pipedream, and I’m looking to make a condition (branch) to not go to the end of the workflow if I’m missing data, do you have the documentation link to do that?
how can I end a workflow early based on a condition?
To end a workflow early based on a condition, you can use the pd.flow.exit()
function within a conditional statement. Here’s an example in Python: def handler(pd: 'pipedream'): # Check your condition here, for example: if some_condition: return pd.flow.exit() print("This code will only run if the condition is not met")
Replace some_condition
with your specific condition. If the condition is met, the workflow will exit early, and the remaining code in the step and any steps below will not run for the current event.
how can I exit a workflow early with Node.js instead?
In a Pipedream workflow, you can exit a workflow early using Node.js by calling return $.flow.exit()
within any code step. This will immediately end the execution of the workflow, and no remaining code in that step or any code or destination steps below will run for the current event. Here’s an example: export default defineComponent({ async run({ steps, $ }) { return $.flow.exit(); console.log("This code will not run, since $.flow.exit() was called above it"); } });
You can also pass a string as an argument to $.flow.exit()
to provide a custom message: export default defineComponent({ async run({ steps, $ }) { return $.flow.exit("End message"); } });
Or exit the workflow early within a conditional: ```
export default defineComponent({ async run({ steps, $ }) { // Flip a coin, running $.flow.exit() for 50% of events if (Math.random() > 0.5) { return $.flow.exit(); } console.log(“This code will only run 50% of the time”); } });