-
Notifications
You must be signed in to change notification settings - Fork 195
Description
Bug report
- Extension name: firestore-stripe-payments (invertase)
Describe the bug
I am trying to get the invertase extension to work with metered pricing but I keep getting the error:
{message: 'Quantity should not be specified where usage_type is metered. Remove quantity from line_items[0]'}
even though I have no quantity part of the addDoc package.
I am not setting the quantity anywhere in my code but I can't get it to work. I have tried setting quantity to null, unset etc but it just gives invalid integer then.
Not sure what else to provide but happy to give any information needed.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
'use client';
import { auth, db } from '@/firebaseConfig';
import type { FirebaseApp } from 'firebase/app';
// make sure db is exported here
import { addDoc, collection, onSnapshot } from 'firebase/firestore';
import { getFunctions, httpsCallable } from 'firebase/functions';
import { logger } from '@/lib/default-logger';
const PRICE_ID = process.env.NEXT_PUBLIC_STRIPE_METERED_PRICE!;
const CLOUD_RUN_ROOT = process.env.NEXT_PUBLIC_CLOUD_RUN_ROOT!;
/**
- Creates a Checkout Session document in
- stripe_customers/{uid}/checkout_sessions
- and waits for the extension to fill in
url
.
*/
export async function getCheckoutUrl(): Promise {
const user = auth.currentUser;
if (!user) throw new Error('Must be signed-in first');
// 1️⃣ Create the Checkout-Session request doc
const sessionRef = await addDoc(collection(db, 'stripe_customers', user.uid, 'checkout_sessions'), {
price: PRICE_ID, // single-price subscription
mode: 'subscription',
success_url: window.location.href,
cancel_url: window.location.href,
metadata: { storeId: user.uid },
});
// 2️⃣ Listen for the extension to populate url
or error
return new Promise((resolve, reject) => {
const unsubscribe = onSnapshot(
sessionRef,
(snap) => {
const data = snap.data();
if (!data) return;
if (data.error) {
unsubscribe();
logger.error('Stripe ext error', data.error);
reject(new Error(data.error.message ?? 'Stripe extension failed'));
}
if (data.url) {
unsubscribe();
resolve(data.url as string);
}
},
(err) => {
unsubscribe();
reject(err);
}
);
setTimeout(() => {
unsubscribe();
reject(new Error('Timed out waiting for Stripe Checkout URL'));
}, 60_000);
});
}
Expected behavior
I expected a checkout window to open where card details can be entered.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- Browser: Chrome
Additional context
N/A