#ab365

1 messages · Page 1 of 1 (latest)

coarse galleonBOT
dapper raven
#

What kind of issues are you having? What's not working like you expect?

graceful pendant
#

well

#

before stripe had the redirecttoChecout functionality

#

but being deprecated i need to do a redirect

#

thing is im using the stripe checkout formated page for the checkout, not a personalized one

#

and i cant figure out how to get that link for the redirect, once they press the button for checkout

#

im using next.js

dapper raven
#

can you share a snippet of your current code?

graceful pendant
#

yes

dapper raven
#

you need to return the session url to the client then redirect to that

graceful pendant
#

this is my react component, where the fucntion to checkout proceeds

#

this code was coppied from the pre built stripe checkout page

#

now am i supposed to create a checkout link?

dapper raven
#

Yea with your fetch approach the 303 redirect wont work

#

You should return the session object for just the url as data to the client, as you would have done before with the data.id

#

It looks like you might have been responding with json of the full session previously

#

in which case you'd redirect to data.url in your client side code

graceful pendant
#

so

#

what would i need to do to make it work thyen

dapper raven
#

What was your code doing server side before you changed it?

#

res.json(session)?

graceful pendant
#

i never changed it

#

it never worked

#

thats why im asking for help

dapper raven
#

You must have -- that redirect(303) wouldn't have worked with your client code

dapper raven
#

i see

#

ok

graceful pendant
#

from the prebuilt checkout page

dapper raven
#

in which case, try changing that to response.send({url: session.url}) or your preferred json payload approach

graceful pendant
#

the res.redirect(303)?

dapper raven
#

Yea that line

graceful pendant
#

ok

#

i changed that

#

but the stripe.redirectToCheckout keeps giving me issues

#

this is the updated code

#

and this is the side im getting issues with

#

line 34

dapper raven
#

Yes, now there is no id and you'd need to redirect to the data.url in the client instead

#

line 34 doesn't make sense any more

graceful pendant
#

ok i will try again and make the changes

#

ok so i dont get issues with that anymore, however i do have console errors with a 400 bad request

#

this is the browser console and my cart element from reactg

still sluice
#

I think there's a typo in your Checkout Session parameters: enables -> enabled

#

I bet that's the API error if you check your Stripe Dashboard

#

The 400 error is likely being thrown by your API call

graceful pendant
#

let me fix and try

#

thanks

#

yes the typo gave me that error

dapper raven
graceful pendant
#

got a 200 ok

#

now it still didnt redirect me to the checkout page

dapper raven
#

What do you client network requests look like? Do you see the session url response coming back like you expect?

graceful pendant
#

well what i would expect is after pressing the button to be sent to the checkout page

#

whihc isnt happening

still sluice
#

It's because you're still using stripe.redirectToCheckout() on the front-end, which expects a cs_xxx ID. But your backend is only returning a url field

graceful pendant
#

i removed that

still sluice
#

You need to do window.location.replace(data.url) or something

graceful pendant
#

o jesus

#

that worked

#

added the window request line on client code and it directed me to checkout

#

i didnt put or set up any business inffo on the profile yet

#

if i do try to make payment will the payment go through and charge me?

#

like, i placed the environment on test so, is it safe to use a card to test if it works ?

still sluice
#

You should be using your test API keys to create test objects/sessions (sk_test_xxx)

#

Then you can use our test cards to facilitate test payments

graceful pendant
#

i think it works

#

yess

#

then i should be set to go

#

?

dapper raven
#

Woohoo! thanks for the suggestion/assist @still sluice

graceful pendant
#

ill take that as a yes then

#

guys, seriously, thank you so much.

#

you guys helping us here means a lot

#

seriously

#

i. ve been killing myuself over this and i couldnt get it right

#

thank you for answering our questions here on discord

#

i wish more companies did the same seriously, thank you so so much

still sluice
graceful pendant
#

will look into that

still sluice
#

Minor difference being it uses server-side redirect

graceful pendant
#

yes

#

im using next.js

#

i will read into it asap thank you @still sluice @dapper raven

#

you guys rock!🤟