#nikivi
1 messages ยท Page 1 of 1 (latest)
Hi ๐ what settings/parameters are you unsure about?
@wild prawn what are the minimal options to create this url
grafbase devs said i should somehow use JWT sub
but not sure where that goes
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
im reading this and its very unclear what is actually needed to be passed
import Stripe from "stripe"
// eslint-disable-next-line turbo/no-undeclared-env-vars
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: "2022-11-15",
typescript: true,
})
export default async function Resolver(_: any, { input }: any) {
const { customerId } = input
try {
const data = await stripe.checkout.sessions.create({
success_url: "https://kuskus.app/success",
mode: "subscription",
customer: customerId,
})
return { url: data.url }
} catch (error) {
console.log(error)
return {
url: "test",
}
}
}
code i have now
resolver is basically a function that gets called
i just need to know what is needed as input
and what object to return
the page i need is basically subscription page
with 7 day free trial
The required parameters are flagged in our API reference for that endpoint:
https://stripe.com/docs/api/checkout/sessions/create
Is there functionality you want to see that isn't being included? Is your code encountering an error saying parameters are missing?
That code is at least missing the line_items parameter, and it will return a Checkout Session object.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh so line_items is needed for subscriptions too
my bad, thought it was only for one time payments
i started with this article but i got error
saying i need it to be mode 'subscription'
ok
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so this url
import Stripe from "stripe"
// eslint-disable-next-line turbo/no-undeclared-env-vars
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: "2022-11-15",
typescript: true,
})
export default async function Resolver(_: any, { input }: any) {
const { lineItems } = input
try {
const data = await stripe.checkout.sessions.create({
success_url: "https://kuskus.app/success",
line_items: lineItems,
mode: "subscription",
})
return { url: data.url }
} catch (error) {
console.log(error)
return {
url: "test",
}
}
}
Yes, line_items is required for any mode other than setup. What was the error? They're usually pretty good about explicitly pointing to the problem.
basically says this should be good
ok trying this now
to see if it works
ok that worked
ok i need a setting for free trial
looking now
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
cant find it here ๐ค
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok that worked, thank you