Skip to content

Commit f13f6f8

Browse files
author
Alex Patterson
committed
adjust collection
1 parent aa30717 commit f13f6f8

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

‎components/user-buy.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function Buy({
4949
const getPrice = async () => {
5050
const price = await getStripePrice({ stripeProduct });
5151
const priceData = price.data() as any;
52-
console.log(priceData);
52+
console.debug(priceData);
5353
setPrice(priceData);
5454
};
5555

‎lib/firebase.ts‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,12 @@ export const getStripePrice = async ({
164164
}
165165

166166
// Get Price
167+
console.debug('query for strip-product', id)
167168
const pricesQuery = await query(
168-
collection(
169-
doc(collection(getFirestore(), "stripe-products"), id),
170-
"prices"
171-
),
169+
collection(getFirestore(), `stripe-products/${id}/prices`),
172170
where("active", "==", true)
173171
);
172+
console.debug('query', pricesQuery)
174173
const pricesSnapshot = await getDocs(pricesQuery);
175174
const price = pricesSnapshot.docs[0];
176175

@@ -200,24 +199,24 @@ export const addSubscription = async ({
200199
collection(userDoc, "checkout_sessions"),
201200
stripeProduct
202201
? {
203-
line_items: [
204-
{
205-
price: price.id,
206-
quantity: 1,
207-
},
208-
],
209-
mode: "payment",
210-
allow_promotion_codes: true,
211-
success_url: window.location.href,
212-
cancel_url: window.location.href,
213-
}
202+
line_items: [
203+
{
204+
price: price.id,
205+
quantity: 1,
206+
},
207+
],
208+
mode: "payment",
209+
allow_promotion_codes: true,
210+
success_url: window.location.href,
211+
cancel_url: window.location.href,
212+
}
214213
: {
215-
mode: "subscription",
216-
allow_promotion_codes: true,
217-
price: price.id,
218-
success_url: window.location.href,
219-
cancel_url: window.location.href,
220-
}
214+
mode: "subscription",
215+
allow_promotion_codes: true,
216+
price: price.id,
217+
success_url: window.location.href,
218+
cancel_url: window.location.href,
219+
}
221220
);
222221
};
223222

0 commit comments

Comments
 (0)