#Jane_Zhong

1 messages ยท Page 1 of 1 (latest)

cursive violetBOT
late pewter
#

๐Ÿ‘‹ happy to help

#
      const account = webhook.data.object;
      const previousAccount = webhook.data.previous_attributes;

      if (account.charges_enabled && !previousAccount.charges_enabled) {
        // The account was just created and is fully set up and ready to process payments
        // Do something with the account data
        console.log("Webhook:user's express account created!", account);
      }
    }
    ```
#

would you mind sharing the webhook endpoint ID? we_xxx

silk nexus
#

Hi tarzan , not at all ,glad to share ๐Ÿ˜„ โ€‹``` app.post(
"/stripe",
bodyParser.raw({ type: "application/json" }),

async (req, res) => {
const sig = req.headers["stripe-signature"];

let event = JSON.parse(req.body);


try {
  event = stripe.webhooks.constructEvent(
    req.body,
    sig,
    process.env.STRIPE_WEBHOOK_SECRET
  );
} catch (err) {
  // On error, log and return the error message
  console.log(`โŒ Error message: ${err.message}`);
  return res.status(400).send(`Webhook Error: ${err.message}`);
}
// for express account
if (event.type === "account.update") {
  const account = webhook.data.object;
  const previousAccount = webhook.data.previous_attributes;

  if (account.charges_enabled && !previousAccount.charges_enabled) {
    // The account was just created and is fully set up and ready to process payments
    // Do something with the account data
    console.log("Webhook:user's express account created!", account);
  }
}


res.json({ received: true });

}
);โ€‹```

#

Are you talking about this ?

late pewter
#

no the ID from your dashboard

silk nexus
#

we_1MjS11Em6oZta2poZAiIVhzz

late pewter
#

thanks

silk nexus
#

To you ๐Ÿ˜„

late pewter
#

so basically as I suspected you created the webhook endpoint to listen on the events of your own account

#

on your dashboard when you create a new Webhook Endpoint you need to specify "Listen on Events on my connected accounts"

#

otherwise the event account.updated will not trigger for you

silk nexus
#

Oh,where can I find it ?

late pewter
#

and you also have a typo it's account.updated and not account.update

late pewter
#

you also need to add the event to the list of events you wish to listen to

#

since in that webhook endpoint there's only payment intent events on your own account

silk nexus
#

The wehook I created for listen to the user's account creation ,could you please help me how to modify it in orde to listen to the user's account create event ?โ€‹```
app.post(
"/stripe",
bodyParser.raw({ type: "application/json" }),

async (req, res) => {
const sig = req.headers["stripe-signature"];

let event = JSON.parse(req.body);

try {
  event = stripe.webhooks.constructEvent(
    req.body,
    sig,
    process.env.STRIPE_WEBHOOK_SECRET
  );
} catch (err) {
  // On error, log and return the error message
  console.log(`โŒ Error message: ${err.message}`);
  return res.status(400).send(`Webhook Error: ${err.message}`);
}
// for express account
if (event.type === "account.update") {
  const account = webhook.data.object;
  const previousAccount = webhook.data.previous_attributes;

  if (account.charges_enabled && !previousAccount.charges_enabled) {
    // The account was just created and is fully set up and ready to process payments
    // Do something with the account data
    console.log("Webhook:user's express account created!", account);
  }
}

res.json({ received: true });

}
);โ€‹```

late pewter
#

it's not the code you should worry about but rather the webhook endpoint creation

silk nexus
late pewter
#

there you need to select Events on Connected accounts as shared by the screenshot earlier

#

and you need to select the events you want to listen to

#

in this case you need to include account.updated

#

one last thing you need to change in your code is the typo I mentioned account.updated insteead of account.update

#

if (event.type === "account.updated") {

silk nexus
#

Ahhh ,I seee ! Thank you so much Tarzan ! You did really helped me !