#Surya-Mani

1 messages ยท Page 1 of 1 (latest)

smoky anchorBOT
trail roost
#

๐Ÿ‘‹ How can I help?

near torrent
#

Im using integrate customer portal ,How it works

trail roost
near torrent
#

I already use that API in my code I shows some url How my customers will redirect to update plan page?

trail roost
#

After you create the Customer Portal link, you will redirect the customer URL and he/she will click update plan button to go update plan page

near torrent
#

How should i do that by get that url and click by customer ?

trail roost
#

Which API do you use? Is /v1/billing_portal/sessions used to create the Customer Portal?

near torrent
#

this one

trail roost
#

The URL will be in session.Url which you can use to redirect the customer to

near torrent
#

yes i will store that url in string

#

How will i redirect manually or it redirect automatically?

smoky anchorBOT
trail roost
#

You should use your code to redirect the URL automatically

winged fog
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

near torrent
#

My code means i dont understand

winged fog
#

basically you have 2 approaches, when your customer clicks on your button in the frontend your code calls the API /create-customer-portal-session
Approach 1: use backend Redirect function, which automatically redirects the customer to the right page (basically sending a 3xx HTTP response)
Approach 2: send the session.Url to the frontend and use window.location = sessionUrl to redirect in the frontend

#

both approaches achieve the same thing

#

the code you shared uses the 1st approach

near torrent
#

Where should i use window.location = sessionUrl ,In frontend or backend?

winged fog
#

you don't need to if you use the 1st Approach, which is the one used in the code you shared

near torrent
#

I need to use 2nd

near torrent
#

ok

#

Then i have another one doubt

winged fog
#

just a fair question why do you need to use the 2nd approach? what are your constraints?

near torrent
#

I dont know how to redirect so only i ask about it

#

Whicj approach is easy

winged fog
#

the 1st one

#

you just need to copy/paste the code

#

and it will work

near torrent
#

these two codes right

#

1st one is for frontend and second one is for backend a i right?

winged fog
#

yes

near torrent
#

ok thank you

#

i have another one doubt

winged fog
#

sure

near torrent
#

in this page after clicking confirm button where the customers will be redirect?

winged fog
#

is this in the Customer Portal?

near torrent
#

yes

winged fog
#

they will be redirected to the Return URL once they're done from the portal

near torrent
#

one minute

#

I will get the url for update plan page in session.url

near torrent
#

Hello

winged fog
#

yes I'm here

#

what's the question?

near torrent
#

If i paste that url in browser i will get update plan page

winged fog
#

yes

near torrent
#

After select the plan it asking for confirm

#

and after click confirm where i shoul i redirect

#

Im using angular for frontend

winged fog
#

you shouldn't do anything

#

this page is a Stripe hosted page

near torrent
#

No

#

Im using my page

#

this is my page

winged fog
#

this is not your page, this is Stripe Customer Billing Portal as you can see from the URL billing.stripe.com

near torrent
#

i will get this url from here

#

You already said for approach 1 just copy/paste the code

#

but i click the button i didn't get any response

smoky anchorBOT
spark talon
#

Hi! I'm taking over this thread.

#

I'm not sure I understand the question. Once users are on te customer portal, they stay on the customer portal unless they click on the "return" link in the left of the page.

near torrent
#

Did you see that code i have sent

spark talon
#

Yes

#

The highlighted line is the session URL, that's where you should send your users to update their subscriptons.

near torrent
#

i will use this but no response

#

I'm using angular for frontend ,is this code is works on angular

spark talon
#

This is just HTML so yes it should work.
What's the issue exactly? Do you see an error message in your browser or in your backend?

near torrent
#

No i click that button but nothing happens

spark talon
#

I need more information to help. Something must happen: an error message in your browser, console, or backend code.

near torrent
#

Anycode should need to add in typescript file

spark talon
#

I cannot help without more information about the error you see.

near torrent
#

Only this html code is enough for frontend?

spark talon
#

Yes, it's just a form, so no JavaScript is needed here. However you need to make sure your backend is running and has a /create-customer-portal-session route that is working with no errors

near torrent
#

I got this when i run my backend code

spark talon
#

Next step is to check your backend log for the exact error, and fix that errir.

near torrent
#

is this is an problem

spark talon
#

What do you mean?

near torrent
#

Is this is the problem in my backend?

spark talon
#

Are you a software developer?

near torrent
#

I'm fresher

spark talon
#

I'm sorry I don't understand, what does that mean?

#

I want to help you, but you are not answering my questions:

  1. Are you a software developer?
  2. What exact errors do you see in your backend logs? The screenshot you shared doesn't help much.
  3. Also can you share your backend code that is throwing the error?
near torrent
#
  1. I'm junior developer trainee
#

I'm asking you this is error or not in that screenshot

#

var options = new Stripe.BillingPortal.SessionCreateOptions
{
Customer = "cus_OI7ZQG2pgkiUG8", ///cus_O5lEsCPkUsTi2M
ReturnUrl = "https://reinvent-learning.us/",
};
var service = new Stripe.BillingPortal.SessionService();
// var service = new SessionService();
var session = service.Create(options);
string Url = session.Url;
return Redirect(session.Url);

#

this is my backend code

spark talon
#

The screenshot you shared is not enough.

#

How did you start your backend server?

near torrent
#

is this is ok?

#

sorry i don't understand what you are asking?

spark talon
#

Thanks, having a look.

near torrent
#

ok

spark talon
#

Looks like there is some CORS configuration issue with your backend. You are using dotNET?

near torrent
#

Yes i'm using .Net

#

This is the issue for my error , am i right?

smoky anchorBOT
terse dome
#

Hey! Taking over for my colleague. Let me catch up.

terse dome
# near torrent

According to this screenshot, you are trying to run a redirection via swagger UI

#

Did you try to run it from a frontend framework ?

near torrent
#

Yes

#

yes by using angular

terse dome
#

could you please share a screenshot for the error using angular ?

near torrent
#

I will click the button but nothing will happens

terse dome
#

Share a video screen recording with the devtool console opened

#

for both network and javascript

near torrent
#

ok

#

This is the code i'm using in my frontend

#

In frontend no error will show in browser nad console

near torrent
#

after run my backend code it shows this

#

Did you have any samples for how webhooks works?

#

this is our CORS policy

terse dome
# near torrent this is our CORS policy

It seems your cors policy isn't enabling those connection. You need to search in community how you need to solve your backend cors error, this has no link with Stripe APIs.

near torrent
#

Ok i will check

#

Which community?

terse dome
#

I don't know you need to google for it and how you can set/implement CORS policies with the framework you are using actually in your backend (.NET ?)

near torrent
#

Ok

#

This is the issues for my error?

terse dome
#

Your backend is blocking your frontend from making requests, that has no link with Stripe APIs. You need to debug/update your integration in order to update you CORS policies.

near torrent
#

Ok thank you

#

Did you have samples for how webhooks works?

terse dome