Skip to content

Commit

Permalink
clients/web: handle case of a user upgrade from free to paid tier
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Nov 22, 2024
1 parent 6775621 commit 07d8ffe
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {

import { InlineModalHeader } from '@/components/Modal/InlineModal'
import { useStorefront, useUpdateSubscription } from '@/hooks/queries'
import { api } from '@/utils/api'
import { formatCurrencyAndAmount } from '@polarkit/lib/money'
import { useRouter } from 'next/navigation'
import Button from 'polarkit/components/ui/atoms/button'
Expand Down Expand Up @@ -134,6 +135,14 @@ const ChangePlanModal = ({
router.push(
`/${organization.slug}/products/${subscription.product_id}`,
)
} else if (body.error === 'MissingPaymentMethod') {
const { url } = await api.checkouts.clientCreate({
body: {
product_price_id: selectedPrice.id,
subscription_id: subscription.id,
},
})
router.push(url)
}
}
}
Expand Down

0 comments on commit 07d8ffe

Please sign in to comment.