OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
improve: billing
Carl-Gerhard Lindesvärdc06d446a46a4
diff --git a/apps/api/src/controllers/webhook.controller.ts b/apps/api/src/controllers/webhook.controller.tsindex 788e2741a..1506d8839 100644--- a/apps/api/src/controllers/webhook.controller.ts+++ b/apps/api/src/controllers/webhook.controller.ts@@ -130,6 +130,10 @@ export async function polarWebhook(}>,reply: FastifyReply,) {+ request.log.info('polar webhook raw', {+ rawBody: request.rawBody,+ headers: request.headers,+ })try {const event = validatePolarEvent(request.rawBody!,@@ -137,6 +141,12 @@ export async function polarWebhook(process.env.POLAR_WEBHOOK_SECRET ?? '',);+ request.log.info('polar webhook event', {+ rawBody: request.rawBody,+ headers: request.headers,+ event,+ })+switch (event.type) {case 'order.created': {const metadata = zdiff --git a/apps/start/src/components/organization/billing.tsx b/apps/start/src/components/organization/billing.tsxindex a6809f129..04c5e66a0 100644--- a/apps/start/src/components/organization/billing.tsx+++ b/apps/start/src/components/organization/billing.tsx@@ -52,6 +52,7 @@ export default function Billing({ organization }: Props) {useWS(`/live/organization/${organization.id}`, () => {queryClient.invalidateQueries(trpc.organization.pathFilter());+ queryClient.invalidateQueries(trpc.subscription.pathFilter());});const [recurringInterval, setRecurringInterval] = useState<'year' | 'month'>(@@ -92,7 +93,7 @@ export default function Billing({ organization }: Props) {organization.subscriptionCurrentPeriodEnd) {return (- <p>+ <p className="text-destructive">Your subscription will be canceled on{' '}{formatDate(organization.subscriptionCurrentPeriodEnd)}</p>@@ -104,7 +105,7 @@ export default function Billing({ organization }: Props) {organization.subscriptionCurrentPeriodEnd) {return (- <p>+ <p className="text-destructive">Your subscription expired on{' '}{formatDate(organization.subscriptionCurrentPeriodEnd)}</p>diff --git a/apps/start/src/modals/billing-success.tsx b/apps/start/src/modals/billing-success.tsxindex 748717f6f..d68e6f52d 100644--- a/apps/start/src/modals/billing-success.tsx+++ b/apps/start/src/modals/billing-success.tsx@@ -33,7 +33,7 @@ export default function BillingSuccess() {</div>{/* Success Message */}- <h2 className="text-3xl font-semibold mb-4 text-gray-900">+ <h2 className="text-3xl font-semibold mb-4">Subscription updated successfully</h2><p className="text-center mb-12 max-w-md text-base leading-normal">diff --git a/apps/start/src/modals/select-billing-plan.tsx b/apps/start/src/modals/select-billing-plan.tsxindex 3f0c64601..25d2cbe31 100644--- a/apps/start/src/modals/select-billing-plan.tsx+++ b/apps/start/src/modals/select-billing-plan.tsx@@ -217,9 +217,9 @@ export default function SelectBillingPlan({};return (- <ModalContent>+ <ModalContent className="!flex !flex-col !overflow-hidden"><ModalHeader title="Select a billing plan" />- <div className="col gap-4">+ <div className="col gap-4 shrink-0">{currentProduct && (<div className="font-medium">Your current usage is{' '}@@ -257,7 +257,7 @@ export default function SelectBillingPlan({</Button></div></div>- <div className="col divide-y divide-border border rounded-lg overflow-hidden">+ <div className="col divide-y divide-border border rounded-lg overflow-y-auto min-h-0">{products.filter((product) =>product.prices.some((p) => p.amountType !== 'free'),@@ -282,7 +282,7 @@ export default function SelectBillingPlan({type="button"disabled={isProductDisabled}className={cn(- 'row justify-between p-4 py-3 hover:bg-def-100',+ 'row justify-between p-4 py-3 hover:bg-def-100 shrink-0',currentProduct?.id === product.id &&selectedProductId !== product.id &&'text-muted-foreground line-through',@@ -303,7 +303,7 @@ export default function SelectBillingPlan({);})}</div>- {renderAction()}+ <div className="shrink-0">{renderAction()}</div></ModalContent>);}