#nikivi
1 messages · Page 1 of 1 (latest)
i want to deploy my app finally
Can you share the event id?
evt_1N8io4KmRnbuc3WvwmPbLb95
perhaps this
not sure which one it was
I have few questions also to simplify the code if I may ask
One thing at a time
ok
lets solve first thing
i had it working yesterday
its just im trying to deploy now
That event wasn't sent to any endpoints it looks like
ok let me go over what i did
my app has 4 pricing points
i now have this switch case
if it passes either of these 4 strings
it creates a new session
I don't know if i can turn monthly to yearly
as one session as part of parameter
would simplify code
otherwise i thought I made 4 products
is what I have now
Ok
I just need an event id to investigate the webhook issue
And your code snippet for that endpoint
ok so code is here
i run via node index.js
on node 18
in nother tab i run stripe listen --forward-to localhost:4242/webhook
import * as dotenv from "dotenv"
actually it might be i missed this
as i added those process.env
going to try with this
ah this is some node troubles
i tried running it with bun
as it auto loads .env
but thats what caused this
so i guess bun is not supported
https://bun.sh is bun
or maybe i have wrong code
You said it was working yesterday. What changed?
So before it worked with just hardcoding the variables?
yes
it only worked for 2 payments
i since added year
with discount
needed to set those up
but first want to get 2 working
i assume year is just passing a paramter
ok go it running
const dotenv = require("dotenv")
had to use this
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY)
for some reason stripe docs use old require syntax
not es6
so everything has to be require now
So it's working now?
What is your code doing
Send your webhook endpoint code
it listens to events
Oh you did thanks
So for some reason you're getting undefined events being sent to the endpoint
What made those requests to the endpoint?
That corresponded to the "Unhandled event type" errors
so i do this
which calls this function
for normalMonthly
it creates this session
and returns url from it
which is what i click and fill details
after filling payment
stripe calls that web hook endpoint
thats my understanding of it at least
in theory
case "checkout.session.completed":
should fire
but i get undefined i guess
Oh
It might not be pulling in your env variables
Log endpointSecret as the first line in your endpoint code
Make sure it's actually pulling in the variable
yes you are right
do i need to move dotenv.config()
into the app.post?
app.post(
"/webhook",
express.raw({ type: "application/json" }),
async (request, response) => {
dotenv.config()
like so?
never worked with express + env vars
yea that did not help 😦
trying with this
const dotenv = require("dotenv")
dotenv.config()
// This is your test secret API key.
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY)
this*
okk
that worked
i get stuff back
thank god
ok now how can i may year plans work without duplicating code
for creating sessions
or I can't
the way it works
subscription.current_period_end
i use this to update user model
to know the date until user is subscribed
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
reading this
can't find period
or something like this
seems i have to make whole new product for it
Just create different prices under the same product: https://stripe.com/docs/products-prices/pricing-models#flat-rate
ok doing it this way
@shut drift is it possible
i realise i created all these projects
live
can i copy to test
or i have to manually redo
products*
Have to manually
You can create multiple prices under the same product though
Would make sense to have 2 products: KusKus and KusKus Pro
Then you could have all the different pricing options under those 2 products as different price objects in stripe
i thought it was thesse things
where do i get url
const normalMonthly = await stripe.checkout.sessions.create({
success_url: process.env.STRIPE_SUCCESS_URL!,
mode: "subscription",
metadata: {
userDetailsId: userDetailsId,
},
line_items: [
{
quantity: 1,
price: process.env.STRIPE_NORMAL_MONTH_SUBSCRIPTION!,
},
],
})
return {
stripeCheckoutUrl: normalMonthly.url,
}
is my code
where STRIPE_NORMAL_MONTH_SUBSCRIPTION
is that id
yea
cant find in ui
price urls
@shut drift
i did how you said
not helpful 😦
im actually surprised
i remember using those ids before
why did it suddently start breaking
Can you share the request id
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You passed a price id to the success_url
ok that is fixed
but this
it should say 1 year
its in test mode
STRIPE_NORMAL_YEAR_SUBSCRIPTION=price_1N9ZKsKmRnbuc3WvqnUTPFqa
i make sure its right
maybe its no up to date?
tried again
oh
i see it shows description there
so like
@shut drift
What's the problem?
if i do this thing
with 2 products
and 2 prices
how can i show 1 year here
i thoguht thats what this was for
Create a new session and see if it's fixed
just did
thats new
removed description
thought it would fix it
now it shows nothing
price descirption?
ok doing this update
yea
no change
anything else i can try?
Paste the checkout session id or link so I can take a look
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this is api
how in dashboard
No the actual checkout session link
I still see no description
Create a new link now
im confused
A new checkout session
That looks like the exact same link you just sent
case "normalYearly":
const normalYearly = await stripe.checkout.sessions.create({
success_url: process.env.STRIPE_SUCCESS_URL!,
mode: "subscription",
metadata: {
userDetailsId: userDetailsId,
},
line_items: [
{
quantity: 1,
price: process.env.STRIPE_NORMAL_YEAR_SUBSCRIPTION!,
},
],
})
return {
stripeCheckoutUrl: normalYearly.url,
}
so every time it hits this
it returns same one
is this expected
No
Are you passing an idempotency key?
i dont
its just this
ok
this is first time i make this link
its still no description
should be this
is it some caching issue or something
im confused
also i have question
in my web hook code
how can I know that on case "checkout.session.completed":
it was pro product
and not normal
i can send metadata
but i wonder if there is way to do without
like if I can get name of product
in the checkout session
ok can do that