diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx index be9c46dc57e..2341607f003 100644 --- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx +++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx @@ -28,10 +28,7 @@ const AddNewPaymentMethodModal: FC = ({ visible, onCancel }) => { const setupIntent = async () => { setIntent(undefined) const orgSlug = ui.selectedOrganization?.slug ?? '' - const customerId = ui.selectedOrganization?.stripe_customer_id ?? '' - const intent = await post(`${API_URL}/organizations/${orgSlug}/payment/setup-intent`, { - customer_id: customerId, - }) + const intent = await post(`${API_URL}/organizations/${orgSlug}/payments/setup-intent`, {}) setIntent(intent) } diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx index ab517c8aadc..de23d8e25a6 100644 --- a/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx +++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx @@ -141,9 +141,14 @@ const PaymentSummaryPanel: FC = ({

Retrieving payment methods

) : paymentMethods.length === 0 ? ( - // [TODO] We need some UI to allow users to add payment methods here -
-
No methods
+
+
+ +

No saved payment methods

+
+
) : ( diff --git a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade/index.tsx similarity index 99% rename from studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx rename to studio/components/interfaces/Billing/ProUpgrade/index.tsx index d350b853dd0..4c78d74a0be 100644 --- a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx +++ b/studio/components/interfaces/Billing/ProUpgrade/index.tsx @@ -1,6 +1,5 @@ import { FC, useEffect, useState } from 'react' import { Transition } from '@headlessui/react' -import { useRouter } from 'next/router' import { Badge, Button, IconArrowLeft, IconHelpCircle, Toggle, Modal } from '@supabase/ui' import { useStore } from 'hooks' @@ -34,7 +33,6 @@ const ProUpgrade: FC = ({ onSelectBack, }) => { const { ui } = useStore() - const router = useRouter() const { addons } = products const projectRef = ui.selectedProject?.ref diff --git a/studio/components/interfaces/Billing/index.ts b/studio/components/interfaces/Billing/index.ts index 6b24fcfe902..d942ea1fe77 100644 --- a/studio/components/interfaces/Billing/index.ts +++ b/studio/components/interfaces/Billing/index.ts @@ -2,7 +2,7 @@ import PAYGUsage from './PAYGUsage/PAYGUsage' import Subscription from './Subscription/Subscription' import PlanSelection from './PlanSelection' -import ProUpgrade from './ProUpgrade/ProUpgrade' +import ProUpgrade from './ProUpgrade' import EnterpriseRequest from './EnterpriseRequest' import ExitSurvey from './ExitSurvey/ExitSurvey' import PaymentSummaryPanel from './PaymentSummaryPanel' diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsx index 72035f72b3d..1c8b6307ecf 100644 --- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx +++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx @@ -36,13 +36,10 @@ const BillingUpdatePro: NextPage = () => { if (projectRef) { getStripeProducts() getSubscription() + getPaymentMethods() } }, [projectRef]) - useEffect(() => { - if (stripeCustomerId) getStripeAccount() - }, [stripeCustomerId]) - const getStripeProducts = async () => { try { setIsLoadingProducts(true) @@ -58,20 +55,21 @@ const BillingUpdatePro: NextPage = () => { } } - const getStripeAccount = async () => { + const getPaymentMethods = async () => { + const orgSlug = ui.selectedOrganization?.slug ?? '' try { setIsLoadingPaymentMethods(true) - const { paymentMethods, error: customerError } = await post(`${API_URL}/stripe/customer`, { - stripe_customer_id: stripeCustomerId, - }) - if (customerError) throw customerError + const { data: paymentMethods, error } = await get( + `${API_URL}/organizations/${orgSlug}/payments` + ) + if (error) throw error setIsLoadingPaymentMethods(false) setPaymentMethods(paymentMethods) } catch (error: any) { ui.setNotification({ error, category: 'error', - message: `Failed to get subscription: ${error.message}`, + message: `Failed to get available payment methods: ${error.message}`, }) } } @@ -106,7 +104,7 @@ const BillingUpdatePro: NextPage = () => { products={products} currentSubscription={subscription} isLoadingPaymentMethods={isLoadingPaymentMethods} - paymentMethods={paymentMethods?.data ?? []} + paymentMethods={paymentMethods || []} onSelectBack={() => router.push(`/project/${projectRef}/settings/billing/update`)} />