#ab365

1 messages · Page 1 of 1 (latest)

obtuse mountainBOT
brisk kiln
#

Yes we now suggest using the url and redirecting directly to that

#

i cant find it in the object he sent

unborn galleon
#

hello thank you

brisk kiln
#

Can you say more about this? WHere are you looking>?

unborn galleon
#

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

brisk kiln
#

OK, and whats the problem exactly?

unborn galleon
#

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

plush heron
#

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?

unborn galleon
#

so following this tutorial there is the function that has to be created

#

using the redirect to checkout option that is deprecated now

plush heron
#

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?

unborn galleon
#

Yes

#

I could attach the whole code file

#

If that helps

#

Or the github file

plush heron
#

No need, do you the Stripe call to create the checkout session in your endpoint code?

unborn galleon
#

i dont understand sorry

#

this part is not form the end point is from a react component

plush heron
#

So it looks like the intended process is:

  1. This component reaches out to your server's endpoint
  2. Your server creates a checkout session and sends data back to the client
  3. The client is redirected to the Checkout page
unborn galleon
#

yes

#

hence the redirectToCheckout

plush heron
#

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

unborn galleon
#

once they press the button proceed to checout it would execute that funcition

plush heron
#

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

unborn galleon
#

for my backend

#

this is what i copied from stripe website

plush heron
#

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?

unborn galleon
#

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

plush heron
#

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

unborn galleon
#

at least to see it in the console

plush heron
#

You can actually remove the redirectToCheckout here, your client should redirect as soon as it gets that 303 with the URL

unborn galleon
#

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

plush heron
#

Was this code working before? Or has it always told you that all of the Stripe things are undefined?

unborn galleon
#

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.

young pulsar
#

Hi there 👋 taking over

Give me a few minutes to get caught up.

unborn galleon
#

okay thanks

young pulsar
#

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?

unborn galleon
#

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

young pulsar
#

Hmmm, are you sure the getStripe() function is being called somewhere? If so, where is it being called from?

unborn galleon
#

you will find the import and below where its being called

#

the function getStripe()

young pulsar
#

Okay, but do you know it's being called?

unborn galleon
#

no

young pulsar
#

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.

unborn galleon
#

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

young pulsar
#

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?

unborn galleon
#

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()

young pulsar
# unborn galleon here

I don't see a reference to handler() in there anywhere. I see a reference to handleCheckout(), but not to handler()

unborn galleon
#

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

unborn galleon
# unborn galleon

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

young pulsar
#

Where in your HTML is the button? Do you see it referencing handler()?

unborn galleon
young pulsar
#

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()

unborn galleon
#

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'

young pulsar
#

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?

unborn galleon
#

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

young pulsar
#

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.

unborn galleon
#

Ok