stripe-firebase-extensions
stripe-firebase-extensions copied to clipboard
FirebaseError on createCheckoutSession
Bug report
- firestore-stripe-web-sdk
Describe the bug
FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
at ba (index.esm2017.js?4515:14943)
at FirestoreSessionDAO.eval (session.js?995f:116)
at Generator.next (<anonymous>)
at eval (session.js?995f:22)
at new Promise (<anonymous>)
at __awaiter (session.js?995f:18)
at FirestoreSessionDAO.addSessionDoc (session.js?995f:115)
at FirestoreSessionDAO.eval (session.js?995f:110)
at Generator.next (<anonymous>)
at eval (session.js?995f:22)
It seems that the firestore instance created in the FirestoreSessionDAO isn't correct or the collection() call is wrong.
To Reproduce
Init firebase and stripe
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp()
const payments = getStripePayments(app, {
productsCollection: 'products',
customersCollection: 'customers'
})
export { app, payments }
import payments and use checkout function
import { payments } from '../services/firebase.service'
import { createCheckoutSession, } from '@stripe/firestore-stripe-payments'
...
methods: {
checkout () {
createCheckoutSession(payments, {
price: 'price_1Jtax3GhjnzZribLiyQznali'
}).then(session => {
window.location.assign(session.url)
}).catch(err => {
console.log(err)
})
}
}
...
When the method gets called there's the error in the console.
Expected behavior
Normal stripe checkout session.
System information
Windows, Chrome, [email protected], @stripe/[email protected]
Additional context
Add any other context about the problem here.
Same problem: https://stackoverflow.com/questions/70013565/stripe-and-firebase-firebaseerror-expected-first-argument-to-collection-to-b?noredirect=1#comment123784766_70013565
Same problem here, possibly related to Firebase ^9 ?
My firebase version: "firebase": "^9.1.3"
This is likely a dependency management issue. The library is expecting a certain version of @firebase/firestore
while a different one is installed with the app. Can somebody who can repro this issue please share their dependency tree with us (i.e. npm ls
output)? Or even better, share a small, minimal repro that we can try locally.
├── @emotion/[email protected] ├── @emotion/[email protected] ├── @firebase/analytics 2@ extraneous ├── @firebase/app-check 2@ extraneous ├── @firebase/app-check-compat 2@ extraneous ├── @firebase/app-compat 2@ extraneous ├── @firebase/[email protected] ├── @firebase/auth-compat 2@ extraneous ├── @firebase/database 2@ extraneous ├── @firebase/database-compat 2@ extraneous ├── @firebase/firestore 2@ extraneous ├── @firebase/firestore-compat 2@ extraneous ├── @firebase/functions 2@ extraneous ├── @firebase/functions-compat 2@ extraneous ├── @firebase/installations 2@ extraneous ├── @firebase/messaging 2@ extraneous ├── @firebase/messaging-compat 2@ extraneous ├── @firebase/performance 2@ extraneous ├── @firebase/performance-compat 2@ extraneous ├── @firebase/remote-config 2@ extraneous ├── @firebase/storage 2@ extraneous ├── @firebase/storage-compat 2@ extraneous ├── @material-ui/[email protected] ├── @mui/[email protected] ├── @mui/[email protected] ├── @stripe/[email protected] ├── @testing-library/[email protected] ├── @testing-library/[email protected] ├── @testing-library/[email protected] ├── faye-websocket 2@ extraneous ├── firebase 2@ extraneous ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]
├── @chakra-ui/[email protected] ├── @emotion/[email protected] ├── @emotion/[email protected] ├── @fontsource/[email protected] ├── @stripe/[email protected] extraneous ├── @types/[email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]
Guys now it seems working! Awesome, thanks!
Guys now it seems working! Awesome, thanks!
What did you change?
Literally nothing. I just tried again to trigger the function and now it just works.
I downgraded from:
"@stripe/firestore-stripe-payments": "0.0.4", to "@stripe/firestore-stripe-payments": "0.0.3",
and the bug stopped occurring.
Attempted downgrading, still have the same issue.
Still have this issue on 0.0.5 by the way
What made it work for me was ensuring that Firebase-related dependencies are the same for both my app and @stripe/firestore-stripe-payments via package.json overrides.
This is how the overrides in my package.json look like for 0.0.6 of the @stripe/firestore-stripe-payments and Firebase JS SDK 9.6.6:
"overrides": { "@firebase/app": "0.7.16", "@firebase/firestore": "3.4.4" }
It's not pretty but it works for now.
i have same with "overrides": { "@firebase/app": "0.7.16", "@firebase/firestore": "3.4.4" }. i'm so confused. Someone have an idea ?
same issue here. using v.0.0.6 of stripe-payments. Tried the solutions mentioned above but that didn't work :(
What made it work for me was ensuring that Firebase-related dependencies are the same for both my app and @stripe/firestore-stripe-payments via package.json overrides.
This is how the overrides in my package.json look like for 0.0.6 of the @stripe/firestore-stripe-payments and Firebase JS SDK 9.6.6:
"overrides": { "@firebase/app": "0.7.16", "@firebase/firestore": "3.4.4" }
It's not pretty but it works for now.
SEE EDIT BELOW
Previous message:
Thanks! I have used command npx howfat -r tree @stripe/firestore-stripe-payments
(also I ran it with firebase package) to see exactly the version I needed, and with [email protected] and @stripe/[email protected] installed I could make it work with the following override:
"overrides": {
"@firebase/app": "0.7.29",
"@firebase/firestore": "3.4.13"
}
EDIT: It broke again with the same settings, for me it's an intermittent issue and it's hard to debug.
Any updates on this? For me using:
"overrides": {
"@firebase/app": "0.7.29",
"@firebase/firestore": "3.4.13"
}
breaks the auth and is not working anyway. I'm getting FirebaseError: Firebase: Error (auth/network-request-failed).
because of incompatibility (I don't have this issue when not using overrides)
Regarding Stripe payments, in my database, in /customers/:userId/checkout_sessions, I have error cannot read propery "stripeId" of null
Idk if this matters but I'm using yarn and resolutions
instead of overrides
Was stuck on this for days. I have a monorepo setup with PNPM workspaces.
Temporarily fixed by forcing up-to-date dependencies by adding:
"pnpm": {
"overrides": {
"@stripe/[email protected]>@firebase/app": "0.8.2",
"@stripe/[email protected]>@firebase/auth": "0.20.10",
"@stripe/[email protected]>@firebase/firestore": "3.7.1"
}
}
to my root package.json
. The particular versions where set to match the others I found commands like pnpm -F [app-name] why @firebase/app
Experiencing this to. Very frustrating.
Update: so the fix is to force your package.json to use whatever version of these packages is listed in your firebase dependency (eg. by using resolutions
if using yarn
):
"@firebase/app" "@firebase/auth" "@firebase/firestore"
Experiencing this to. Very frustrating.
Update: so the fix is to force your package.json to use whatever version of these packages is listed in your firebase dependency (eg. by using
resolutions
if usingyarn
):"@firebase/app" "@firebase/auth" "@firebase/firestore"
Thank you for your solution Same issue here... I hope this problem will be solved
For those who don't know how to make a "resolution", here's what I did in package.json:
{
"resolutions": {
"@firebase/app": "0.8.2",
"@firebase/auth": "0.20.10",
"@firebase/firestore": "3.7.1"
},
}
Don't forget to run yarn install
Experiencing this to. Very frustrating. Update: so the fix is to force your package.json to use whatever version of these packages is listed in your firebase dependency (eg. by using
resolutions
if usingyarn
):"@firebase/app" "@firebase/auth" "@firebase/firestore"
Thank you for your solution Same issue here... I hope this problem will be solved
For those who don't know how to make a "resolution", here's what I did in package.json:
{ "resolutions": { "@firebase/app": "0.8.2", "@firebase/auth": "0.20.10", "@firebase/firestore": "3.7.1" }, }
Don't forget to run yarn install
Thanks bro!
after so much time looking for a solution!
This break again with "firebase": "^10.1.0"
???
This is happening for me too using "^10.1.0" I've tried adding resolutions to the package.json file but no luck.
Any way to get around this or solve it @dackers86 ? Thank you
@byroncoetsee, were you able to resolve this, please? I am also on firebase: 10.0.0
This break again with
"firebase": "^10.1.0"
???
@RasicN , any solutions? i am also on 10.0.0 and having the same issue
Was able to find a fix for ^10.0.0
Basically, the resolutions need to match whatever the current version you are using so for this version this worked:
"resolutions": {
"@firebase/firestore": "4.1.3",
"@firebase/auth": "1.3.0",
"@firebase/app": "0.9.18"
},
I just went to node_modules/firebase/package.json
and copied the versions from there, I am sure there is a yarn
command you can use to find that
I personally gave up on waiting and simply queried the tavbles myself, that works quite nicely but is a little extra work that we frankly expected Stripe to do...
@surafelbm's solution worked for me with slightly different version on npm:
"dependencies": {
"@invertase/firestore-stripe-payments": "^0.0.7",
"firebase": "10.1.0",
},
"overrides": {
"@firebase/app": "0.9.15",
"@firebase/auth": "1.1.0",
"@firebase/firestore": "4.1.0"
}
Note: If you use npm
, use override
instead of yarn's resolutions
Same problem still isn't fixed till this day. This temporary fix works as everyone above already said:
"overrides": { "@firebase/app": "0.9.25", "@firebase/auth": "1.5.1", "@firebase/firestore": "4.4.0" }
I got the collection error before but using overrides to override the dependencies to the firebase package versions I get another error:
Uncaught (in promise) Error: Unexpected error while querying Firestore
at FirestoreProductDAO.<anonymous> (@invertase_firestore-stripe-payments.js?v=c3306c19:665:15)
at Generator.throw (<anonymous>)
at rejected (@invertase_firestore-stripe-payments.js?v=c3306c19:493:32)
I am getting nowhere with this Firebase Extension...
I got the collection error before but using overrides to override the dependencies to the firebase package versions I get another error:
Uncaught (in promise) Error: Unexpected error while querying Firestore at FirestoreProductDAO.<anonymous> (@invertase_firestore-stripe-payments.js?v=c3306c19:665:15) at Generator.throw (<anonymous>) at rejected (@invertase_firestore-stripe-payments.js?v=c3306c19:493:32)
I am getting nowhere with this Firebase Extension...
Be sure you are having the rules of db set correctly. I've managed to not have any errors anymore, everything works fine for me. Maybe share more of your code to understand your problem