Home > Net >  When to update the db with the created order. Firebase Firestore, React, Stripe
When to update the db with the created order. Firebase Firestore, React, Stripe

Time:12-22

Ideal Scenario.

  1. The user makes the order.
  2. Firebase Server sends the request to Stripe.
  3. Stripe Confirm Payment Method and sends a webhook to Firestore. At this point, I can create the order on the server. But:
    1. webhook sometimes is fast and others not
    2. need to create a temp order and update it later with the data from the hook

Problems till here

  1. how to know the id of the created order to update later?
  2. is there some way to send data automatically from the server to the client?

CodePudding user response:

The most common way to handle this is to attach metadata to your PaymentIntent with a UUID for your Order ID. At the same time you create a corresponding order in your database. Then, that same Order ID will come through via your Webhook (via the metadata you set) when the payment has been completed and you update your database accordingly for that order.

  • Related