#Shannon-trials
1 messages ยท Page 1 of 1 (latest)
Hello! that really depends on what kind of solution you're trying to build. If you're trying to use Checkout or Payment Links that would need a different solution compared to if you were working with Subscription objects directly. Which of our products are you hoping to use?
I followed along with this video: https://www.youtube.com/watch?v=P0Udy2Gi7n8
In this video, we'll set up subscription payments using Next.JS, Firebase, and Stripe. Using Firebase's "Run Subscription Payments with Stripe" Firebase extension to easily integrate all the tools together.
With this extensive guide, we'll set up the following:
- Create a new Next.JS project
- Set up Authentication in Firebase
- Created a Fires...
I'm very new however I believe it's checkout links.
stripe.redirectToCheckout({ sessionId });```
Gotcha, if it's Checkout you can set subscription_data.trial_end or subscription_data.trial_period_end when you create the Checkout Session (see https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_end)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Would that be here? ```const newData = {
price: "price_1KOYp0LI6lJiE72tFu8GsjoO",
success_url: window.location.origin,
cancel_url: window.location.origin,
};
const collRef = collection(firestoreDb, `users/${uid}/checkout_sessions`);
const checkoutSessionRef = await addDoc(collRef, newData);```
Is that your client-side code? You would need to make these changes in the server-side call that is creating the Checkout Session
Not sure. Here's the code... initializeStripe.tsx ```import {Stripe, loadStripe} from "@stripe/stripe-js";
let stripePromise: Stripe | null;
const initializeStripe = async () => {
if (!stripePromise) {
stripePromise = await loadStripe("pk_test_xxxxx");
}
return stripePromise
};
export default initializeStripe;and createCheckoutSession.tsimport { getFirestore, addDoc, collection, onSnapshot, doc } from "firebase/firestore";
import getStripe from "./initiateStripe";
export async function createCheckoutSession(uid: string) {
// const firestone = firebase.firestore();
const firestoreDb = getFirestore();
// Create a new checkout session in the subcollection inside this user's document
try {
const newData = {
price: "price_1KOYp0LI6lJiE72tFu8GsjoO",
success_url: window.location.origin,
cancel_url: window.location.origin,
};
const collRef = collection(firestoreDb, users/${uid}/checkout_sessions);
const checkoutSessionRef = await addDoc(collRef, newData);
const idk = onSnapshot(checkoutSessionRef, async (checkoutSessionData) => {
console.log("Current data: ", checkoutSessionData.data());
const { sessionId } = checkoutSessionData.data();
if (sessionId) {
// We have a session, let's redirect to checkout
// Init Stripe
const stripe = await getStripe();
stripe.redirectToCheckout({ sessionId });
}
});
console.log("Document written with ID: ", checkoutSessionRef.id);
} catch (e) {
console.error("Error adding document: ", e);
}
}
Based on info from this video https://www.youtube.com/watch?v=P0Udy2Gi7n8
In this video, we'll set up subscription payments using Next.JS, Firebase, and Stripe. Using Firebase's "Run Subscription Payments with Stripe" Firebase extension to easily integrate all the tools together.
With this extensive guide, we'll set up the following:
- Create a new Next.JS project
- Set up Authentication in Firebase
- Created a Fires...
and help from the firebase discord to migrate the code from firebase v8 to v9.
Hi ๐ karbi had to step away so I'm getting caught up
Okay so the createCheckoutSession.ts appears to be your server-side code. That's where the information about the subscription trial period will need to go
Ok, I would like to use the trial_period_days if possible.
but unsure the location/format. I assume it'll be added to the firestore save and then used to call the session?
I don't know about using Firestore in particular.
It looks like you are specifying Session parameters in the const newData declaration though.
If I understand the code I'm saving the session data to the database and then using this data under const stripe = await getStripe(); stripe.redirectToCheckout({ sessionId });
Yeah so in that case you would include the subscription data shown here: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data
which includes the trial_period_days parameter
I just added it like this which saved it to the database as follows and this info was passed to the redirectToCheckout method.
Is this the proper format to have the tiral_period_days as an object/sub under subscription_data?
Appears to be correct based on this article: https://saasbase.dev/subscription-payments-1-adding-basic-and-pro-subscription-plans-using-stripe/
And you are using your test keys?
Yeah, the checkout is working. It's just the full price with no trial data
with test keys
Is this price set up to be a recurring subscription or a one off?
Reoccurring monthly
Based on the info under redirectToCheckout I don't believe this is possible.
Okay so it appears the Firebase extension has not fully implemented all current features of Checkout. Unfortunately this means you can only use the trial_from_plan: true parameter. You would need to set the trial on the Price record in the dashboard.
seems like it's not a option under the redirectToCheckout according to the info for this online.
What do you mean by set the trial on the price record? under the product itself?
the section that says legacy?
Yes. It is legacy but it still works
who maintains the firebase extension?
When is the plan to phase it out?
I forgot that installing that extension was part of the video.
Looks to be a stripe product. Any information on when this extension will be updated?
This is one of the libraries that Stripe does maintain. I am looking to see if I can find information on any update/deprecation calendars
I can verify that the stripe-firebase extension will allow you to use the trial_from_plan: true parameter.
Where do I access trial_from_plan?
It does work when I use the legacy trial on the product itself. I would like to try and not use legacy code though where this is a new project. Don't want it breaking as soon as it launches. LOL
I realize this is less than ideal. There is an open issue on the stripe-firebase-extension Github for supporting trial_period_days. This would be good to follow so you can recieve updates when it is added.
There is no plan for this functionality to go away any time soon.
Sorry: here's the issue link https://github.com/stripe/stripe-firebase-extensions/issues/274
Yeah, just found it.
The last comment 5 days ago appears to be a stripe dev because it appears to be the same guy from the video that from stripe on the stripe-cli
Yes it is maintained by Stripe. I don't know the individual employees but it is something we as a company maintain.
ok, cool.
At least it's a known issue.
I'll use the legacy for now and hopefully will see an update on the repo in the coming days/months before they stop supporting the trial under product
Appreciate it.