forked from coracle/caravel
fix: stripe portal dead-end with callback return flow (#67)
Co-authored-by: userAdityaa <aditya.chaudhary1558@gmail.com> Co-committed-by: userAdityaa <aditya.chaudhary1558@gmail.com>
This commit is contained in:
@@ -40,7 +40,7 @@ export default function PaymentSetup(props: PaymentSetupProps) {
|
||||
setRedirecting(true)
|
||||
setError("")
|
||||
try {
|
||||
const { url } = await createPortalSession(account()!.pubkey)
|
||||
const { url } = await createPortalSession(account()!.pubkey, window.location.href)
|
||||
window.location.href = url
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "Failed to open billing portal")
|
||||
|
||||
@@ -253,8 +253,9 @@ export function reactivateRelay(id: string) {
|
||||
return callApi<undefined, void>("POST", `/relays/${id}/reactivate`)
|
||||
}
|
||||
|
||||
export function createPortalSession(pubkey: string) {
|
||||
return callApi<undefined, { url: string }>("GET", `/tenants/${pubkey}/stripe/session`)
|
||||
export function createPortalSession(pubkey: string, returnUrl?: string) {
|
||||
const query = returnUrl ? `?return_url=${encodeURIComponent(returnUrl)}` : ""
|
||||
return callApi<undefined, { url: string }>("GET", `/tenants/${pubkey}/stripe/session${query}`)
|
||||
}
|
||||
|
||||
export function getInvoiceBolt11(invoiceId: string) {
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function Account() {
|
||||
async function openPortal() {
|
||||
setPortalLoading(true)
|
||||
try {
|
||||
const { url } = await createPortalSession(account()!.pubkey)
|
||||
const { url } = await createPortalSession(account()!.pubkey, window.location.href)
|
||||
window.location.href = url
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "Failed to open billing portal")
|
||||
|
||||
Reference in New Issue
Block a user