#Shannon-trials

1 messages ยท Page 1 of 1 (latest)

viral oak
#

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?

celest prairie
#

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...
โ–ถ Play video
#

I'm very new however I believe it's checkout links.

#
        stripe.redirectToCheckout({ sessionId });```
viral oak
celest prairie
#

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);```
viral oak
#

Is that your client-side code? You would need to make these changes in the server-side call that is creating the Checkout Session

celest prairie
# viral oak Is that your client-side code? You would need to make these changes in the serve...

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...
โ–ถ Play video
#

and help from the firebase discord to migrate the code from firebase v8 to v9.

proper maple
#

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

celest prairie
#

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?

proper maple
#

I don't know about using Firestore in particular.

#

It looks like you are specifying Session parameters in the const newData declaration though.

celest prairie
#

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 });

proper maple
#

which includes the trial_period_days parameter

celest prairie
#

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?

proper maple
#

And you are using your test keys?

celest prairie
#

Yeah, the checkout is working. It's just the full price with no trial data

#

with test keys

proper maple
#

Is this price set up to be a recurring subscription or a one off?

celest prairie
#

Reoccurring monthly

#

Based on the info under redirectToCheckout I don't believe this is possible.

proper maple
#

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.

celest prairie
#

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?

proper maple
#

Yes. It is legacy but it still works

celest prairie
#

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?

proper maple
#

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.

celest prairie
#

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

proper maple
#

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.

celest prairie
#

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

proper maple
#

Yes it is maintained by Stripe. I don't know the individual employees but it is something we as a company maintain.

celest prairie
#

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.

proper maple
#

๐Ÿ‘

#

The legacy approach should be stable and work reliably. They wouldn't deprecate that feature until well after they enable a replacement.

celest prairie
#

Yeah, makes sense.

#

Thanks again!