Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

260
Vistas
How do i solve this error: FirebaseError: Expected type 'mc', but it was: a custom yc object?

I created a app on Nextjs (js) and Firebase. And I added Stripe extension to make a subscription system. I'm not very experienced with this new version 9 of firebase so it was hard to do this because I followed a tutorial that using version 8 and ts. I still managed to make most of the things work except this that is giving me this error.

This is the tutorial: https://youtu.be/P0Udy2Gi7n8?t=859 (my problem at 14:19)

I'm having the error here:

import getStripe from "./initializeStripe";
import { db } from '../firebase/firebaseClient'
import { doc, getDoc, addDoc, setDoc, setCol, onSnapshot, collection } from "firebase/firestore";

export async function createCheckoutSession(uid) {

    const docData = {
        price: "price_1KvNgoI6qyGEmrlgKU3miVmT",
        success_url: window.location.origin,
        cancel_url: window.location.origin,
    };
  
    const checkoutSessionRef = await setDoc(collection(db, "users", uid, "checkout_sessions"), docData); //ERROR


    onSnapshot(getDoc(doc(checkoutSessionRef)), (snap) => {
        const { sessionId } = snap.data();

        if (sessionId) {
            // We have a session, let's redirect to checkout
            // Init Stripe
            const stripe = getStripe();
            stripe.redirectToCheckout({ sessionId })
        }
    });

The error is the following:

Unhandled Runtime Error FirebaseError: Expected type 'mc', but it was: a custom yc object

Browser

Firebase config

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The setDoc() takes a DocumentReference as first parameter but you are passing a CollectionReference. Try using addDoc() instead:

await addDoc(collection(db, "users", uid, "checkout_sessions"), {...data})

This will add a document with a randomly generated document ID. If you want to use specify the document yourself, then you can use setDoc() as shown below:

await setDoc(doc(db, "users", uid, "checkout_sessions", "DOC_ID"), {...data})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda