#furkanayilmaz-checkout

1 messages ยท Page 1 of 1 (latest)

spice stone
sacred prism
#

So if there is a product that is $39.99 and you click it gives you a link and you go back and choose a different product the price and url doesn't change and when you click on the link that it returns for the new product the price stays at $39.99

spice stone
#

I assume your integration is creating a new Checkout Session each time the user cilcks on a product, right?

sacred prism
#

const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
mode: "payment",
line_items: [
{
price_data: {
currency: "usd",
product_data: {
name: "Ride Request",
},
unit_amount: convertedPrice,
},
quantity: 1,
},
],
mode: 'payment',
success_url: http://localhost:3000/success,
cancel_url: http://localhost:3000,
}).then((response) => {
// console.log(response.url)

    app.post("/payment", (req, res) => {
        console.log(currentOption, convertedPrice)
        res.send(response.url)
        //console.log(response.url);
    })
}).catch((err) => {
    console.log(err)
})
#

This is the code

#

That does the checkout

spice stone
#

Do you have examples of the request IDs made to create these Checkout Sessions?

sacred prism
#

Or where can I find it

spice stone
sacred prism
#

Here is one of the request ID

#

req_A1XeUox67njb94

#

So when I generate a link for 30 dollar item the link generates and the item price is 30 and when I go back and click on a different the link is same as the item that was $30 and the price is also same

#

I can also send the full code for the server that generates the link

spice stone
#

Looking at the two most recent requests on your account I see that you created one Checkout Session with a unit_amount of 9100 and another with 3300. When you click on the next price, are you being directed to the same checkout link or a different one?

spice stone
#

What exactly is your code doing? Are you making sure to make a request to your backend to create a new Checkout Session each time a product is clicked?

sacred prism
#

So when you choose a new product it goes to the Checkout Session and creates a new session

spice stone
#

And are you making sure that the you are redirecting the correct checkout session URL? It should be generating a new URL if a new CHeckout Session is being created

sacred prism
#

This is the code

#

The code that should be generating the link is in the server file and called server.js and there is another file in components file

#

That is rideselector

#

That is the code that contacts with the server and create the link

spice stone
#

Why is your Checkout Session creation request then making another request to "/payment"? Why aren't you juse sending back the Checkout session URL right there?

#

Your code seems to be using a framework I'm not super familiar with, but I'm guessing the issue lies with your "/payment" endpoint sending back the wrong Checkout session URL

sacred prism
sacred prism
mighty nimbus
#

๐Ÿ‘‹ Hi I was just lurking in this thread to do some reviewing but I think I see something that might be causing a problem.

mighty nimbus
#

The URL to the checkout session is being returned in the session object on line 59 of server.js

mighty nimbus
#

In order to access the Checkout URL I think you can redirect your users to the session.url parameter

sacred prism
#

But doesnโ€™t the promise return a result already

mighty nimbus
#

I would start by inspecting the flow and making sure each of the objects is what you expect it to be.

sacred prism
#

All the data is being being forwarded to server correctly. I did do console.log to check every data

mighty nimbus
#

I just don't think the URL being returned in the .then block is the session URL. I would try skipping the .then() block altogether and just redirect to session.url

#

What is getting written into session currently appears to be modified by the then() block.

sacred prism
#

I see! Because much as I know promise returns the result but I will make sure Iโ€™ll give it a try for session.url

mighty nimbus
#

Well you await1 the promise so you should just get the data object back.

sacred prism
#

Let me take a look.

mighty nimbus
#

Here's the docs on the session, just as a handy reference

sacred prism
#

So there is a chance that .then block modifying the url

mighty nimbus
#

I would just suggest commenting out the then() block and redirecting the flow to the session.url property. I think that should work ๐Ÿคž

sacred prism
#

Cool! Let me give that a try

#

@mighty nimbus Thank you so much. It worked. I can't thank you enough.

#

Now the url chances and as well as the price

#

You solved the problem in 10 minutes and I have been trying to solve this the past days

mighty nimbus
#

Awesome! Happy to Help ๐Ÿ‘‹

sacred prism
#

Hey @mighty nimbus

#

So I came across another problem and that is weird

#

So when I console.log(session.url) I get the right url for every product but when I forward it to the frontend I still have the same problem where the price stays the same

#

Have a look at this video

#

This is my screen recording showing the issue

#

In the server the url is right but when being forwarded to frontend the url doesn't work properly

maiden fulcrum
#

Hi there,

sacred prism
#

Hi

maiden fulcrum
#

Please allow to step in to help and follow up with your question

sacred prism
#

paymentURL() is the function that gets the url from the backend

#

and being called inside of the ConfirmButtonContainer

#

in the return statement

#

@maiden fulcrum Did you see the video I posted.

#

the one in the google drive

chilly whale
#

Hi @sacred prism so basically opening the checkout URL that you received from Stripe shows the product with the correct price. am I right?

sacred prism
#

Yes, when I open the link that server is returning it shows the correct item price. If you taked a look at the video you can understand the situation better

#

It shows the correct product with the correct price when I opened the link that server returns but when I open the link when I forward it to the frontend it shows the wrong price

chilly whale
#

Can you check your code and see if the url variable is cached?

sacred prism
chilly whale
#

I think you are more familiar with your code than me.

sacred prism
#

Sorry for the late respond

#

Had some issues with my pc

chilly whale
#

No problem. I guess the issue is resovled? ๐Ÿ™‚

sacred prism
#

Yeah and I was able to check and see if the url variable is cached

chilly whale
#

Nice, happy to hear that

sacred prism
#

but for some reason the url in the backend is right but when the url is being forwarded to frontend everything is wrong

#

I have been working on this the past day

#

I have this issue in my mind all day long

#

at work etc