#nikivi

1 messages · Page 1 of 1 (latest)

main flareBOT
junior coyote
#

Hi! Let me help you with this.

#

What's the question?

torpid parcel
#
  try {
    const data = await stripe.checkout.sessions.create({
      success_url: "http://localhost:3000/success",
      mode: "subscription",
    })
    return { url: data.url }
  } catch (error) {
    console.log(error)
  }
#

so i have this now

#

i get this error back

#

i kind of get it

#

but the thing is that i have the product here

#

like shouldn't i be referncing it

#

basically I want to setup a payment page for 10$/month

#

i started reading this doc

#
line_items: [{
    # For metered billing, do not pass quantity
    quantity: 1,
    price: price_id,
  }],
#

it wants me to do this

#
    const data = await stripe.checkout.sessions.create({
      success_url: "http://localhost:3000/success",
      mode: "subscription",
      line_items: [{
        quantity: 1,
        price: "10",
      }],
    })
#

so this in my case i guess

#

or wait its id

junior coyote
junior coyote
torpid parcel
#

wait so im confused

#

im trying to find price_id now

#

in dashboard

junior coyote
torpid parcel
#

i need one of these

junior coyote
#

The Price has an ID price_xxx, you need to pass it in line_items

torpid parcel
#

this right?

#

ok that returns something

#

i thought ```
try {
const data = await stripe.checkout.sessions.create({
success_url: "http://localhost:3000/success",
mode: "subscription",
line_items: [
{
quantity: 1,
price: "price_1N4NrWKmRnbuc3WvWhmp93hl",
},
],
})
return {
suggestedTasks: null,
stripeCheckoutUrl: data.url,
}

#

the .url will contain the url to the checkout session

#

like for context

#

this is an endpoint that checks if user can do an action, if not, it returns with a stripe payment url

#

thats what I thought should happen

#

basing it of this

#

ok that actually seems to return the thing, issue is on grafbase side

#

thank you @junior coyote

junior coyote
#

Please don't share your Secret key.

torpid parcel
#

oops

#

i thought i was on test thing

#

i pressed the test button

#

can i rotate it?

#

or should i create new product now to be safe

junior coyote
junior coyote
torpid parcel
#

@junior coyote if you can help more would be grateful

#

im now doing this basically

#

there is surprisingly now js snippet

#

Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.

#

im using this as my front end

#

i thought the code would look something like this

#

above is for google sign in callback

#

i created my route

#

then this i assume should be this

#

but i need to get checkout_session_id somehow 🤔

junior coyote
#

Hey, sorry, this is a bit too much info. Let's go step by step 😉

#

What are you trying to achieve?

torpid parcel
#

so i managed to show this

#

when users pay, they will go to success_url

#

when they go to that URL, I in my case should do a graphql query to my db saying that this user now has paid

#

i don't know how to do last part

#

essentially this value flipped

#

not sure if it should be boolean

#

and i should check monthly to flip it or it should be a date

#

until the subscription is valid, probably date is more sensible

#

but in any way, not really sure how to approach solving this

junior coyote
torpid parcel
#

oh thats smarter

#

so web hook will do graphql query

#

if I do a web hook

#

the success page can just info basically, hey thanks for paying

junior coyote
#

For webhook you will need to create a REST endpoint. And within it you can update your DB directly.

torpid parcel
#

no more logic done there

#

For webhook you will need to create a REST endpoint

#

is my database essentially

#

there is no rest endpoint

#

there is a resolver i can create

#

but that would be a graphql too

#

will it work?

junior coyote
#

Please, let me know if you have any other questions.