#Preet

1 messages ยท Page 1 of 1 (latest)

honest geyserBOT
hoary temple
#

Hello ๐Ÿ‘‹
Just to clarify, you're seeing this client-side correct? When you try to load checkout?

quartz stag
#

yes

hoary temple
#

How exactly are you redirecting to checkout?

quartz stag
hoary temple
#

is the error printing out when you log res or are you seeing a response object being printed where there's a checkout URL?

#

You can try setting the Checkout session URL to window.location.href

#

let me know if that helps @quartz stag

quartz stag
#

I think I found the issue.
Cors issue is being thrown at this request

#

any idea why?

hoary temple
#

that's because axios.post can't follow the redirect your server is trying to make

#

I haven't used axios enough but there might be a way to tell it to follow the server side redirect ๐Ÿ˜…

The easiest way would be to respond with session.url from your server side and then tell your client-side code to go to that URL

#

so instead of res.redirect(...)

You can do

res.json({ url: session.url })

and on client side,

const data = res.json();
window.location.href = data.url
quartz stag
#

okay I think it will work now, thanks !

hoary temple
#

๐Ÿ‘

#

Happy to help ๐Ÿ˜„

quartz stag
#

Hey Hanzo, I have another doubt.

#

This is the url it redirects to after successful payment

#

As per my applications flow, I want to run some logic once the payment is done, for example like updating database, etc. Someone advised me about using webhooks but I dont know how to start

sand sky
#

Hi, stepping in -- please give me some time to catch up here

quartz stag
#

okay

#

I have added this webhook api in my server. The only doubt is how to call this api once the payment is done by the user

sand sky
#

Can you clarify what you mean with 'how to call this api once the payment is done by the user'?

quartz stag
sand sky
quartz stag
#

I am still a bit confused. So I create the checkout object and send it to the client side. The client side then redirects the user to the checkout URL it got from the object.
Where does this step of retrieving the checkout object comes into the picture? Do I make a separate API for it? Where does its code go?

sand sky
#

You'd need to make a separate API call to retrieve this data on the server side, after the session is complete

quartz stag
#

but how would I know if the session is complete? Arent we doing this to check if the session is complete?

sand sky
#

After you get the session webhook event that the session is complete. After the session is complete, you want to dave the payment details into your database no? If not, can you please help me better understand what you're ultimately trying to achieve?

quartz stag
sand sky
quartz stag
#

is there a way other than using stripe cli to create a webhook point where the events could get transferred to?

#

locally

sand sky
quartz stag
#

I tried adding my localhost:3001/webhook as the webhook URL from the dashboard but it only accepts public URLs. There's an option for testing in a local environment but I will have to use stripe cli to create a webhook.