Skip to content

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

@capelski

Description

@capelski

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions