Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Ensure that payment summary panel shows the correct pricing for existing add ons, and also select the correct price id when generating subscription preview

Joshen Lim5294cf3bf5ec
diff --git a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
index 7f0ce60de28..baa92eec157 100644
--- a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
@@ -45,7 +45,7 @@ const ComputeSizeSelection: FC<Props> = ({
>
<div className="space-y-3">
<h5 className="text-sm text-scale-1200">
- Your project currently has the {currentComputeSize.name}
+ Your project currently has the {currentComputeSize.name} included
</h5>
<p className="text-sm text-scale-1100">
If you would like to change your compute size, do reach out to us
diff --git a/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
index 1cf3b9ad9fc..f9b3bf07f83 100644
--- a/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
@@ -43,7 +43,7 @@ const CustomDomainSelection: FC<Props> = ({
>
<div className="space-y-3">
<h5 className="text-sm text-scale-1200">
- Your project currently has custom domains enabled
+ Your project currently has custom domains included
</h5>
<p className="text-sm text-scale-1100">
If you would like to disable custom domains, do reach out to us
diff --git a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
index 40cffc8fda7..7c3ee62c70f 100644
--- a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
@@ -81,7 +81,7 @@ const PITRDurationSelection: FC<Props> = ({
>
<div className="space-y-3">
<h5 className="text-sm text-scale-1200">
- Your project currently has {currentPitrDuration.name}
+ Your project currently has {currentPitrDuration.name} included
</h5>
<p className="text-sm text-scale-1100">
If you would like to change your PITR duration, do reach out to us
diff --git a/studio/components/interfaces/Billing/Billing.utils.ts b/studio/components/interfaces/Billing/Billing.utils.ts
index cef7e645d4c..644e6e1d7a9 100644
--- a/studio/components/interfaces/Billing/Billing.utils.ts
+++ b/studio/components/interfaces/Billing/Billing.utils.ts
@@ -46,9 +46,12 @@ export const formSubscriptionUpdatePayload = (
region === 'af-south-1'
? []
: [
- computeSize.prices[0].id,
- pitrDuration?.prices?.[0].id,
- customDomains?.prices?.[0].id,
+ computeSize.prices.find((price) => price.id === computeSize.metadata.default_price_id)
+ ?.id,
+ pitrDuration.prices.find((price) => price.id === pitrDuration.metadata.default_price_id)
+ ?.id,
+ customDomains.prices.find((price) => price.id === customDomains.metadata.default_price_id)
+ ?.id,
].filter((x) => x !== undefined)
const proration_date = Math.floor(Date.now() / 1000)
return {
diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
index f5e1df50f67..299b9f0cdba 100644
--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
@@ -55,8 +55,6 @@ const EnterpriseUpdate: FC<Props> = ({
const customDomainOptions = formatCustomDomainOptions(addons)
const currentAddons = getCurrentAddons(currentSubscription, addons)
- console.log({ currentAddons })
-
// [Joshen TODO] Ideally we just have a state to hold all the add ons selection, rather than individual
// Even better if we can just use the <Form> component to handle all of these. Mainly to reduce the amount
// of unnecessary state management on this complex page.
@@ -248,6 +246,7 @@ const EnterpriseUpdate: FC<Props> = ({
isSpendCapEnabled={true}
isSubmitting={isSubmitting}
isRefreshingPreview={isRefreshingPreview}
+ currentSubscription={currentSubscription}
subscriptionPreview={subscriptionPreview}
// Current subscription configuration based on DB
currentPlan={currentSubscription.tier}
diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
index 7405534e4d2..7d1d8ee6fd6 100644
--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
@@ -3,7 +3,7 @@ import * as Tooltip from '@radix-ui/react-tooltip'
import { Listbox, IconLoader, Button, IconPlus, IconAlertCircle, IconCreditCard } from 'ui'
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { checkPermissions, useFlag, useStore } from 'hooks'
+import { checkPermissions, useStore } from 'hooks'
import { PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'
import { SubscriptionPreview } from '../Billing.types'
import { getProductPrice, validateSubscriptionUpdatePayload } from '../Billing.utils'
@@ -12,11 +12,13 @@ import InformationBox from 'components/ui/InformationBox'
import { DatabaseAddon } from '../AddOns/AddOns.types'
import { getPITRDays } from './PaymentSummaryPanel.utils'
import ConfirmPaymentModal from './ConfirmPaymentModal'
+import { StripeSubscription } from '../Subscription/Subscription.types'
// [Joshen] PITR stuff can be undefined for now until we officially launch PITR self serve
interface Props {
isRefreshingPreview: boolean
+ currentSubscription?: StripeSubscription
subscriptionPreview?: SubscriptionPreview
currentPlan: any
@@ -24,6 +26,7 @@ interface Props {
computeSize: DatabaseAddon
pitrDuration: DatabaseAddon
customDomains: DatabaseAddon
+ supportPlan?: DatabaseAddon
}
selectedPlan?: any
@@ -53,6 +56,7 @@ interface Props {
const PaymentSummaryPanel: FC<Props> = ({
isRefreshingPreview,
isSpendCapEnabled,
+ currentSubscription,
subscriptionPreview,
currentPlan,
@@ -154,7 +158,9 @@ const PaymentSummaryPanel: FC<Props> = ({
{/* Add on details */}
{projectRegion !== 'af-south-1' && (
<div className="space-y-1">
- <p className="text-sm">Selected add-ons</p>
+ <p className="text-sm text-scale-1100">Selected add-ons</p>
+
+ {/* Compute size */}
<div className="flex items-center justify-between">
<p
className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}
@@ -164,7 +170,12 @@ const PaymentSummaryPanel: FC<Props> = ({
<p
className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}
>
- ${(getProductPrice(currentAddons.computeSize).unit_amount / 100).toFixed(2)}
+ $
+ {(
+ ((currentSubscription?.addons ?? []).find(
+ (addon) => addon.prod_id === currentAddons.computeSize.id
+ )?.unit_amount ?? 0) / 100
+ ).toFixed(2)}
</p>
</div>
{isChangingComputeSize && (
@@ -175,6 +186,8 @@ const PaymentSummaryPanel: FC<Props> = ({
</p>
</div>
)}
+
+ {/* PITR Duration */}
{currentAddons.pitrDuration?.id !== undefined && (
<div className="flex items-center justify-between">
<p
@@ -189,7 +202,12 @@ const PaymentSummaryPanel: FC<Props> = ({
isChangingPITRDuration ? 'text-scale-1100 line-through' : ''
} text-sm`}
>
- ${(getProductPrice(currentAddons.pitrDuration).unit_amount / 100).toFixed(2)}
+ $
+ {(
+ ((currentSubscription?.addons ?? []).find(
+ (addon) => addon.prod_id === currentAddons.pitrDuration.id
+ )?.unit_amount ?? 0) / 100
+ ).toFixed(2)}
</p>
</div>
)}
@@ -201,6 +219,8 @@ const PaymentSummaryPanel: FC<Props> = ({
</p>
</div>
)}
+
+ {/* Custom Domains */}
{currentAddons.customDomains?.id !== undefined && (
<div className="flex items-center justify-between">
<p
@@ -215,7 +235,12 @@ const PaymentSummaryPanel: FC<Props> = ({
isChangingCustomDomains ? 'text-scale-1100 line-through' : ''
} text-sm`}
>
- ${(getProductPrice(currentAddons.customDomains).unit_amount / 100).toFixed(2)}
+ $
+ {(
+ ((currentSubscription?.addons ?? []).find(
+ (addon) => addon.prod_id === currentAddons.customDomains.id
+ )?.unit_amount ?? 0) / 100
+ ).toFixed(2)}
</p>
</div>
)}
@@ -228,6 +253,21 @@ const PaymentSummaryPanel: FC<Props> = ({
</div>
)}
+ {/* Support Plan */}
+ {currentAddons.supportPlan !== undefined && (
+ <div className="flex items-center justify-between">
+ <p className="text-sm">{currentAddons.supportPlan?.name}</p>
+ <p className="text-sm">
+ $
+ {(
+ ((currentSubscription?.addons ?? []).find(
+ (addon) => addon.prod_id === currentAddons.supportPlan?.id
+ )?.unit_amount ?? 0) / 100
+ ).toFixed(2)}
+ </p>
+ </div>
+ )}
+
{/* Show information boxes with regards to change in subscriptions */}
<div className="!mt-4 space-y-4">
{isChangingPITRDuration && (