#aooa-checkout-lineitems
1 messages · Page 1 of 1 (latest)
Hello aooa1009, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
• https://discord.com/channels/841573134531821608/1162130771386056785, 6 days ago, 11 messages
aooa-checkout-lineitems
@potent olive that's impossible, our API does not support per line-item metadata/details like this. The best option is to store this in your own system/database, or globally on the Checkout Session's own metadata
yes on that line 51 you have one metadata key/value and you can add more
okk
do i have to define it somewhere
in the stripe dashboard
as a string
i keep getting the error
those are just pictures with no real info
no
i addedit to my metadata
i have 2 types of products
one a subscription and another buying loose credits
when they buy a subcription, they get some credits
they can buy loose credits as well
so when the api/webhooks/stripe/route.ts runs
and a subscription purchase or credits purchase is made
sorry those are a lot of really short sentences with no info.
Please breathe, take a step back from your own code and focus on your exact question, developer to developer
because the error it gives me is Type 'string | number' is not assignable to type 'number | undefined'. Type 'string' is not assignable to type 'number'.
sorry,
im trying to explain the scenario
const stripeSession = await stripe.checkout.sessions.create({ success_url: successUrl, cancel_url: billingUrl, payment_method_types: ['card'], mode: 'subscription', billing_address_collection: 'auto', customer_email: email, line_items: [ { price: stripePriceId, quantity: 1 } ], metadata: { userId: userId, creditsGiven: creditsGiven } })
here, can i just automatically add an attr to metadata
or do i need to se its type somewhere, like the stripe dashboard
everything inside metadata is always a string
ohh
but i need to pass an integer
the number of credits they get from buying the subscription
how can i do that
👋 hopping in here - can you try casting your integer to a string and seeing if that works?
👍
guys
@vale sorrel
it didnt work
i tried variants of typecasting
its a string im trying to cast as an integer
What specifically isn't working? Didn'tyou say it was working before?
i made a mistake in calculating
thinking the credit Count increased after buying a subscripion
but it isnt
just need help with one thing here
What does that have to do with casting a string to an integer?
because the casting isnt happening
i think im doing it wrong
I tried it in a couple of ways
one way
another way
but when i try these methods normally, they are able to cast a string to int
but not in here
I'm using typescript and nextjs if it matters
you mustve typecast metadata to integer before
is this how you do it
What debugging have you done so far? Have you tried logging session1.metadata.creditsGiven to see what value is there
And what's the error you get when you try and cast it?
no error
It needs to increase the creditCount attr of the user by the amount
but it doesnt
Did you log incrementvalue and confirm that's what you expect?
What value did you get?
it doesnt come up on either console
Let's be clear. I see you have 2 condition on L69 and L74. You would want to console.log to see the exact value and type you got there first, before thinking of increment the value
It's more of js casting and debug here
I tried a bunch of things
nothing gets logged
im checking both the console in the terminal
and in the chrome dev tools
im just confused at this point
I'm shot as to why it isnt updating the creditCount
it updates in in the scenario of a credit purchase, but not when they buy a subscription