Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda