get_stripe_id_from_firebase


A supabase function that gets the stripe id from firebase and updates the table within supabase.

  1. Make a request to get the stripe id from firebaseget_stripe_id_from_firebase_uidA firebase function that gets the stripe customer id given a firebase user id. 1. Makes a query to a table given a firebase_user_id 1. Returns the stripe_customer_id found the document within the table exports.get_stripe_id_from_firebase_uid = functions.https.onRequest(async (req, res) => { // Step 1 const uid = req.body.uid; const ref = db.collection(customers).doc(uid); const doc = await ref.get(); // Step 2 const stripeId = doc.data()?.stripeId; return res.status(200).json({
  2. Update the table with the stripe_customer_id requested from firebase
// Step 1
let res = await fetch(uidToStripeIdUrl, {
    method: "POST",
    headers: {
      "content-type": "application/json",
    },
    body: JSON.stringify({ uid: firebaseUid })
  });

// Step 2
const { data, error } = await supabase
      .from("table")
      .update({
        stripe_customer_id,
      })
      .match({ id: record.id });