#ab365
1 messages · Page 1 of 1 (latest)
What kind of issues are you having? What's not working like you expect?
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
can you share a snippet of your current code?
yes
you need to return the session url to the client then redirect to that
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?
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
You must have -- that redirect(303) wouldn't have worked with your client code
the code here was copied from stripe, just added the necessary changes, like the shipping.
from the prebuilt checkout page
in which case, try changing that to response.send({url: session.url}) or your preferred json payload approach
the res.redirect(303)?
Yea that line
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
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
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
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
Make sure you're keeping an eye on your server logs for errors like this, or otherwise check in your developer dashboard: https://dashboard.stripe.com/test/logs/
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
What do you client network requests look like? Do you see the session url response coming back like you expect?
well what i would expect is after pressing the button to be sent to the checkout page
whihc isnt happening
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
i removed that
You need to do window.location.replace(data.url) or something
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 ?
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
Woohoo! thanks for the suggestion/assist @still sluice
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
FWIW, there's a Next.js quickstart here: https://stripe.com/docs/checkout/quickstart?client=next
will look into that
Minor difference being it uses server-side redirect