Skip to content

Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
capelski opened this issue Mar 23, 2025 · 2 comments

Comments

@capelski
Copy link

Bug report

  • Extension name: firestore-stripe-payments

Describe the bug

Calling getProducts,createCheckoutSession or onCurrentUserSubscriptionUpdate raises an error:

Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore

To Reproduce

  • getProducts
import { getProducts, getStripePayments } from '@invertase/firestore-stripe-payments';
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { initializeFirestore } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
initializeFirestore(app, {});
const payments = getStripePayments(app, {
  productsCollection: 'products',
  customersCollection: 'customers',
});

await getProducts(payments);
  • createCheckoutSession
import { createCheckoutSession, getStripePayments } from '@invertase/firestore-stripe-payments';
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { initializeFirestore } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
initializeFirestore(app, {});
const payments = getStripePayments(app, {
  productsCollection: 'products',
  customersCollection: 'customers',
});

getAuth(app).onAuthStateChanged(async (user) => {
  if (user) {
    await createCheckoutSession(payments, {
      price: '...',
    });
});
  • onCurrentUserSubscriptionUpdate
import { getStripePayments, onCurrentUserSubscriptionUpdate } from '@invertase/firestore-stripe-payments';
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { initializeFirestore } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
initializeFirestore(app, {});
const payments = getStripePayments(app, {
  productsCollection: 'products',
  customersCollection: 'customers',
});

getAuth(app).onAuthStateChanged(async (user) => {
  if (user) {
    onCurrentUserSubscriptionUpdate(payments, (snapshot) => {});
  }
});

Expected behavior

The methods don't error out and perform the operations described in the documentation.

Screenshots

Image

System information

  • OS: macOS
  • Browser: Chrome

Additional context

I'm using Typescript 5.6.3 and webpack 5.96.1.

@payner35
Copy link

payner35 commented Apr 1, 2025

This library is no longer maintained. You'll need to pull your products directly from Firestore.

const productsRef = collection(db, "products");
const productsSnapshot = await getDocs(productsRef);

@capelski
Copy link
Author

capelski commented Apr 1, 2025

This library is no longer maintained. You'll need to pull your products directly from Firestore.

const productsRef = collection(db, "products"); const productsSnapshot = await getDocs(productsRef);

Such a shame! The Firebase extension still points to this repository, and the root README.md suggests that Invertase is now maintaing the library.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants