#feni-patel_webhooks
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1303691949546668134
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- feni-patel_api, 12 minutes ago, 6 messages
You'd listen for account.updated events on your Connect webhook and can check fields to compute an 'onboarded' status according to your requirements: https://docs.stripe.com/connect/api-onboarding#review-status
Critical part is that you create a Connect webhook on your platform: https://docs.stripe.com/connect/webhooks
That will only receive events from connected accounts connecting/onboarding to your platform
Okay, can you provide code snippet with nodejs and mongodb?
also can you suggest how can i implement step by step ?
There's a Node example here: https://docs.stripe.com/webhooks/quickstart?lang=node
What do you need help with specifically?
first point is how can implement this account.updated webhooks and how can i test that IsOnboarding flag is updated or not into my database?
You'd start with the guide I just shared
Okay thanks, i will provide more info if i am facing any info.
Okay so i have updated my webhooks code. can you guide me weather i am on right track or not?
app.post('/webhooks', async (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
// Verify the webhook signature
try {
event = stripe.webhooks.constructEvent(req.rawBody, sig, 'your_endpoint_secret');
} catch (err) {
console.error('Webhook signature verification failed:', err.message);
return res.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle the account.updated event
if (event.type === 'account.updated') {
const account = event.data.object;
// Check if the account has completed onboarding
const isOnboarded = account.requirements.currently_due.length === 0;
// Update the restaurant's onboarding status in your database
await Restaurant.updateOne(
{ stripeAccountId: account.id },
{ isOnboarded: isOnboarded }
);
console.log(`Updated onboarding status for account: ${account.id} - Onboarded: ${isOnboarded}`);
} else {
console.log(`Unhandled event type ${event.type}`);
}
// Respond to Stripe
res.status(200).send('Received');
});
I have provided my code for your review. please review it
Did you test it? Try and simulate an event with the CLI
how can i test this into my local system