Skip to content

Commit

Permalink
feat: partner billing plan upgrades (supabase#18311)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevcodez authored Oct 19, 2023
1 parent 651138a commit 9a8647a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const PlanUpdateSidePanel = () => {
}
)

const billingViaPartner = subscription?.billing_via_partner === true
const paymentViaInvoice = subscription?.payment_method_type === 'invoice'

const {
data: subscriptionPreview,
error: subscriptionPreviewError,
Expand Down Expand Up @@ -115,7 +118,7 @@ const PlanUpdateSidePanel = () => {
const onUpdateSubscription = async () => {
if (!slug) return console.error('org slug is required')
if (!selectedTier) return console.error('Selected plan is required')
if (!selectedPaymentMethod) {
if (!selectedPaymentMethod && !paymentViaInvoice) {
return ui.setNotification({ category: 'error', message: 'Please select a payment method' })
}

Expand Down Expand Up @@ -392,19 +395,29 @@ const PlanUpdateSidePanel = () => {
</Modal.Content>

<Modal.Content>
<div className="py-4 space-y-2">
<p className="text-sm">
Upon clicking confirm, your monthly invoice will be adjusted and your credit card will
be charged immediately. Changing the plan resets your billing cycle and may result in
a prorated charge for previous usage.
</p>
<div className="!mt-4">
<PaymentMethodSelection
selectedPaymentMethod={selectedPaymentMethod}
onSelectPaymentMethod={setSelectedPaymentMethod}
/>
{!billingViaPartner ? (
<div className="py-4 space-y-2">
<p className="text-sm">
Upon clicking confirm, your monthly invoice will be adjusted and your credit card
will be charged immediately. Changing the plan resets your billing cycle and may
result in a prorated charge for previous usage.
</p>

<div className="!mt-4">
<PaymentMethodSelection
selectedPaymentMethod={selectedPaymentMethod}
onSelectPaymentMethod={setSelectedPaymentMethod}
/>
</div>
</div>
</div>
) : (
<div className="py-4 space-y-2">
<p className="text-sm">
This organization is billed through one of our partners and you will be charged by
them directly.
</p>
</div>
)}
</Modal.Content>
</Modal>

Expand Down
1 change: 1 addition & 0 deletions studio/data/subscriptions/org-subscription-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type OrgSubscription = {
expiry_year: number
}
project_addons: ProjectAddon[]
billing_via_partner?: boolean
}

export async function getOrgSubscription(
Expand Down

0 comments on commit 9a8647a

Please sign in to comment.