#ab365
1 messages · Page 1 of 1 (latest)
Yes we now suggest using the url and redirecting directly to that
i cant find it in the object he sent
hello thank you
Can you say more about this? WHere are you looking>?
when i press the link it shows me an object ot the right of the page
and also in the instructions on the left side
here
OK, and whats the problem exactly?
well
im trying to find the checkout link for the redirect
the thing is that since now it has to be done with a redirect he or she told me that i will have to use the check out session url
and i cant find that
Can you tell me more about where it isn't showing up? Is it not on the objects that you are getting back when you create the checkout session?
so following this tutorial there is the function that has to be created
using the redirect to checkout option that is deprecated now
So the URL will be from your server side code
It looks like the /api/stripe endpoint on your server creates a checkout session given those cart items. Do you have your code from that endpoint?
No need, do you the Stripe call to create the checkout session in your endpoint code?
i dont understand sorry
this part is not form the end point is from a react component
So it looks like the intended process is:
- This component reaches out to your server's endpoint
- Your server creates a checkout session and sends data back to the client
- The client is redirected to the Checkout page
Your react component is only in charge of part 1 and potentially 3, to do this redirect properly you need to modify something in step 2
once they press the button proceed to checout it would execute that funcition
Which is on this server endpoint
Gotcha, so the easiest ways to do that would be to modify your endpoint so that it sends back the URL for the Checkout Session
Yeah, that actually should work. I was talking about basically that res.redirect(303, session.url) part. Have you already been running that code and the redirect isn't happening?
i havent tried yet
reason being i understood i needed to get a link for the checkout from the strip object i was sent before
problem is since i cant use that redirecttocheckout i can receive an answer in my backend
The link I was talking about is the url property on the session object that you are getting back from our API. That new code should be pulling that correctly
at least to see it in the console
You can actually remove the redirectToCheckout here, your client should redirect as soon as it gets that 303 with the URL
i keep getting undefined
on the console.logs i set up
the one up from my backend gives me undefined response, even tho i have all the keys set up correctly
this is the second console.log still gives me undefined as an answer
seems like loadStripe() gives problems as well
Was this code working before? Or has it always told you that all of the Stripe things are undefined?
always
everytime i tries to execute it with the redirectTocheckout i get the same error
IntegrationError: stripe.redirectToCheckout: You must provide one of lineItems, items, or sessionId.
Hi there 👋 taking over
Give me a few minutes to get caught up.
okay thanks
okay, let's back up and focus on one thing at a time. Can you move the console.log(); to inside the function and try again?
ok
so, when i move in in several parts inside the function, it just doesnt appear in the consolel
console
it still says undefined on dev tools of the browser
Hmmm, are you sure the getStripe() function is being called somewhere? If so, where is it being called from?
you will find the import and below where its being called
the function getStripe()
Okay, but do you know it's being called?
no
If you don't know if it's being called or not, I can't really help you. You need to be able to provide answers about what your code is doing and why in order for us to be able to debug things with you.
i know its not being called
wait
so in my dev tools on browser i got a console log
this console.log is from the function getStripe();
the one that is being undefined is the console log on
here
Okay, so the log line there only fires when a POST request is made to the handler() function. Do you know where your integration might be sending that request? Do you know what action is supposed to be triggering it?
well being the only method i have in the whole app, POST, i has to be on the one i sent at 23:18
where i use the function getStripe()
here
I don't see a reference to handler() in there anywhere. I see a reference to handleCheckout(), but not to handler()
i do not have a reference to handler() from my backend no
i missread that sorry
that function gets called by a button to proceed to check out
but not handler() as you said
my problem is that in the video, since at that time the .redirectToCheckout()was working, once you pressed the check out button, you could at least receive the info in a console log from this file
since that doesnt work anymore im stuck
Where in your HTML is the button? Do you see it referencing handler()?
no it doesnt reference handler()it references this function handleCheckout()
That's why. The button your clicking is not calling handler(), it's calling handleCheckout(). If you want it to call handler() where your console.log() is, then you need to replace handleCheckout() with handler()
ok i changed it
now i get a new error message
TypeError: req is undefined
and this log
Module not found: Can't resolve 'child_process' in '/Users/alejandro/Desktop/Ecommerce/ecommerce/node_modules/stripe/lib'
I think what's happening here is that the handler() function was intended to be used in a different file (hence export on line 4) . If I'm understanding properly, it sounds like you cloned a project from somewhere and it was either mangled upon cloning, or a bunch of stuff was changed after you cloned it.
What are you wanting to achieve here overall? What's the point of having handler() to being with?
well the first is im following a tutorial
and when i check the github files of the proyect thats how they have it
i compare with its files and it looks the same and for some reason his works
the only difference is that he used the redirectToCheckout as it has some months this proyect
My guess is that the handler() code is a red-herring or is being called from somewhere else in the project. It could also just be orphan code that was never removed, so I would recommend trying to figure out if you even need to do anything with handler() before proceeding.
Ok