#Rémy

1 messages · Page 1 of 1 (latest)

heavy coralBOT
cobalt crest
#

Hi there!

#

Can you try to summarize your issue in this new thread?

round anvil
#

Hello !
Of course thank you for creating

#

I don't have a great networking but i will try to upload picture

#

I hope these help you to find a solution 🙂

cobalt crest
#

Are you trying to redirect your users to a Checkout Session URL?

round anvil
#

That is we do here

#

We redirect users to a checkout session to register his payment method

cobalt crest
#

How do you redirect users to the Checkout Session? Can you share your code?

round anvil
#

Ah my apologise for the french in the picture ! Here is the part with the url

round anvil
#

I will look for this

cobalt crest
#

No worries!
What I'd like to know is how exactly you are doing the redirect. Is your backend server returning a URL and your frontend update the URL of the browser? Or is the backend directly returns a redirect response to the frontend? Or something else?

round anvil
#

The backend redirect like you can see it on the picture.
In the front i get an endpoint payment/subscription who do the @Get('subscription') function in the back

#

i will try tu put allow-origin-access: '*' in my cors configuration and it was ok bu i can't allow every root because an error occured for other endpoint.

cobalt crest
#

Your backend code looks correct. And what does your frontend code looks like? Do you make a GET request to your backend?

round anvil
#

Yes. I show you

#

i push the token in the header here

cobalt crest
#

There are two main ways to do the Checkout redirection:

  • Return the checkout.url from your backend, and then on the frontend update the window.location
  • Or do a POST request (like <form action="xxx" method="POST">) on the frontend and then backend can do a res.redirect()
round anvil
#

can you show me an exemple for the first solution ? With the window.location ?

cobalt crest
#

Here it looks like you are doing a GET request with res.redirect(), and I don't think that can work.

round anvil
#

Ok we have do a middle solution...

cobalt crest
#

can you show me an exemple for the first solution ? With the window.location ?
Your backend would return the checkout URL like this: res.json({url: session.url); And then your frontend does a GET request to get that URL, and update window.location to that URL to do the redirection.

round anvil
#

And for the second one there is something to send with the post for the backend ?

cobalt crest
#

But I guess this depends on your integration.

round anvil
#

Ok thank you i will try these solutions and i will tell you the result !