#hasan

1 messages ยท Page 1 of 1 (latest)

ionic prawnBOT
onyx kettle
#

Hi
This looks like a cors error in your integration.

#

Can you share some of your code and how are you dowing the redirection? server/front side ?

celest cairn
#

yes sure

#

server side:
//ConfigurationCreateOptions
var options3 = new SessionCreateOptions
{
Customer = "cus_NOjoutzkLPVc4U",
ReturnUrl = "https://example.com/account",
};
var service = new SessionService();
var session = service.Create(options3);

        return Redirect(session.Url);
#

front: api service: getPortalURL(){
return this.http.get(this.APIBasePath + '/CustomerPortal' , {responseType: 'text'})
}

#

front: component: ngOnInit(): void {this.sharedService.getPortalURL().subscribe((res:any)=>{
this.url = res;
})}
customerPortal(){
window.open(this.url, "_blank")
}

onyx kettle
#

I'm quiet confused here, are you using Stripe Checkout Session or customer portal ? when exactly you are having the error?

#

can you also share a complete screenhot (url, console error log...)

celest cairn
#

I'm using both, but the error is occurring when calling the customer portal url. This is the full server side code after seeing the stripe documentation on customer portal:

#

this is a ss of the console

onyx kettle
onyx kettle
celest cairn
#

you're right, my bad. This is a test account tho, no real payment info or real customers on it. This part here on the front is triggering the error : ngOnInit(): void {this.sharedService.getPortalURL().subscribe((res:any)=>{
this.url = res;
})
} I'm calling the api that returns the url here

onyx kettle
#

and then what are you doing with this.url?

celest cairn
#

I have a button on my website that calls the following function: customerPortal(){
window.open(this.url, "_blank")
}

onyx kettle
#

let me do a quick test...

celest cairn
#

which is why I implemented the other pieces of code, and it is also when the cors problem strated persisting

onyx kettle
#

but when implemented alone it was redirecting me to the portal where the user can only view his/her subscription and invoice history
This is something related just to portal configuration and has no link with redirection. At the end both are urls.

#

Your button

customerPortal(){
    window.open(this.url, "_blank")
  }

should be calling your backend, creating a customer portal and do the redirection in server-side not from your frontend.

celest cairn
#

so does saving the url n a variable on the front and calling the variable have something to do with the cors problem?

#

and how do you suggest I should go about to have a portal with actions like in the demo?

onyx kettle
onyx kettle
#

something like this :

[HttpPost("create-customer-portal-session")]
public async Task<IActionResult> CustomerPortal()
{
  // .. your current code
  var service = new SessionService();
  var session = service.Create(options);

// do the redirection
  return Redirect(session.Url);
}
celest cairn
#

okay will try that, thank you for time and patience ๐Ÿ™