#fedoraus

1 messages · Page 1 of 1 (latest)

alpine ginkgoBOT
maiden summit
#

Hey! Bit of a broad question! Is there a specific use case you're trying to account for?

gaunt prawn
#

yes, i can show you part of my code, using checkout session and retrieving data from stripe webhook

#
  const sigHeader = req.headers['stripe-signature'] || '';
  let event;
  try {
    event = stripe.webhooks.constructEvent(req.rawBody, sigHeader, 'whsec_gqeT2XbtqYqOGR73oUmVljPbdB8GgUYB');
  } catch (error) {
    res.status(400).send('Bad request sent.');
    return;
  }
  functions.logger.info(event);
  console.log(event);
  const {email} = await stripe.customers.retrieve(event.data.object.customer);
  await firestore.doc(email).set({subscription_date: new Date(), interval: 'monthly'}, {merge: true});
  res.sendStatus(200);
});```
#

before the customer clicks checkout, i need to connect firebase user with cutomer user

maiden summit
#

I'm not very familiar with Firebase, but when you receive Stripe webhook event you should have the customerId

#

You are listening to what Webhook event ?

gaunt prawn
#

payment_intent.succeeded

maiden summit
gaunt prawn
#

but how i can connect the uid firebase and customer id from stripe??

maiden summit
gaunt prawn
#

thank you very much!