#took a few days off so im remembering
1 messages · Page 1 of 1 (latest)
Hey if it helps you
I'm just gonna paste my stripe checkout code
export const createStripeCheckoutSession = async (
user: UserEntity,
team: TeamEntity,
knex: Knex,
): Promise<Stripe.Response<Stripe.Checkout.Session>> => {
const noTrial = user.hasUsedTrial || team.demoTeam;
const session = await stripe.checkout.sessions.create({
mode: `subscription`,
success_url: getAppUrl(getDashboardRouteTeamRedirect(team.id)),
cancel_url: getAppUrl(getDashboardRoute()),
// consent_collection: {
// terms_of_service: `required`,
// },
billing_address_collection: `auto`,
customer_email: user.email,
currency: `usd`,
allow_promotion_codes: true,
line_items: [
{
price: process.env.STRIPE_PRO_PRICE,
quantity: 1,
},
{
price: process.env.STRIPE_TEAM_MEMBER_PRICE,
quantity: await countTeamMembers({ teamId: team.id }, knex),
},
],
subscription_data: noTrial
? undefined
: {
trial_period_days: TRIAL_PERIOD_DAYS,
},
metadata: {
teamId: team.id,
isTrial: noTrial ? `false` : `true`,
},
});
return session;
};
all that's needed is the stripe on the server
the session object will have a url that you can then redirect your user to
either through a http 3xx redirect or by getting the url in the browser and triggering a url change
o i just made a different post on the help forum .. hold on lemme back track
ok so i Have 2 files, loadStripe which returns the stripe promise, and the Stripe(secret key) object
I gotta go, just wanted to make sure I share some code if it helps you
your help is graciousl, thank you