From 5ea7053c001401b9d0f198377809aedfdf65f044 Mon Sep 17 00:00:00 2001 From: phamhieu Date: Mon, 3 Jan 2022 16:44:18 +0700 Subject: [PATCH] fix: fall back to use stripe/billing portal --- studio/pages/new/[slug].tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx index 3c3f607e0aa..999011855b0 100644 --- a/studio/pages/new/[slug].tsx +++ b/studio/pages/new/[slug].tsx @@ -411,10 +411,10 @@ const EmptyPaymentMethodWarning = observer( * Get a link and then redirect them * path is used to determine what path inside billing portal to redirect to */ - async function redirectToPortal() { + async function redirectToPortal(path: any) { if (stripeCustomerId) { setLoading(true) - const response = await post(`${API_URL}/stripe/checkout`, { + const response = await post(`${API_URL}/stripe/billing`, { stripe_customer_id: stripeCustomerId, returnTo: `${getURL()}${router.asPath}`, }) @@ -425,8 +425,8 @@ const EmptyPaymentMethodWarning = observer( }) setLoading(false) } else { - const { setupCheckoutPortal } = response - window.location.replace(setupCheckoutPortal) + const { billingPortal } = response + window.location.replace(`${billingPortal}${path ? path : ''}`) } } else { ui.setNotification({ @@ -448,7 +448,11 @@ const EmptyPaymentMethodWarning = observer( It's required to add a default payment method for an organization in order to create a paid project.

-