Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Upgrade path for paddle -> stripe

Matt Roberts1d3c6c4ee275
diff --git a/app/handlers/billing.go b/app/handlers/billing.go
index a1a77002f..517d8bea1 100644
--- a/app/handlers/billing.go
+++ b/app/handlers/billing.go
@@ -28,6 +28,7 @@ func ManageBilling() web.HandlerFunc {
"stripeCustomerID": billingState.Result.CustomerID,
"stripeSubscriptionID": billingState.Result.SubscriptionID,
"licenseKey": billingState.Result.LicenseKey,
+ "paddleSubscriptionID": billingState.Result.PaddleSubscriptionID,
"isCommercial": c.Tenant().IsCommercial,
},
})
diff --git a/app/models/entity/billing.go b/app/models/entity/billing.go
index 06d0841fa..3ac91ef0a 100644
--- a/app/models/entity/billing.go
+++ b/app/models/entity/billing.go
@@ -22,7 +22,8 @@ type BillingPayment struct {
}
type StripeBillingState struct {
- CustomerID string `json:"customerID"`
- SubscriptionID string `json:"subscriptionID"`
- LicenseKey string `json:"licenseKey"`
+ CustomerID string `json:"customerID"`
+ SubscriptionID string `json:"subscriptionID"`
+ LicenseKey string `json:"licenseKey"`
+ PaddleSubscriptionID string `json:"paddleSubscriptionID"`
}
diff --git a/app/services/sqlstore/dbEntities/billing.go b/app/services/sqlstore/dbEntities/billing.go
index 1e3a2a92f..295078e37 100644
--- a/app/services/sqlstore/dbEntities/billing.go
+++ b/app/services/sqlstore/dbEntities/billing.go
@@ -8,4 +8,5 @@ type StripeBillingState struct {
StripeCustomerID dbx.NullString `db:"stripe_customer_id"`
StripeSubscriptionID dbx.NullString `db:"stripe_subscription_id"`
LicenseKey dbx.NullString `db:"license_key"`
+ PaddleSubscriptionID dbx.NullString `db:"paddle_subscription_id"`
}
diff --git a/app/services/sqlstore/postgres/billing.go b/app/services/sqlstore/postgres/billing.go
index f441d3ffa..0922f6a07 100644
--- a/app/services/sqlstore/postgres/billing.go
+++ b/app/services/sqlstore/postgres/billing.go
@@ -47,7 +47,7 @@ func getStripeBillingState(ctx context.Context, q *query.GetStripeBillingState)
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
state := dbEntities.StripeBillingState{}
err := trx.Get(&state,
- `SELECT stripe_customer_id, stripe_subscription_id, license_key
+ `SELECT stripe_customer_id, stripe_subscription_id, license_key, paddle_subscription_id
FROM tenants_billing
WHERE tenant_id = $1`, tenant.ID)
@@ -61,9 +61,10 @@ func getStripeBillingState(ctx context.Context, q *query.GetStripeBillingState)
}
q.Result = &entity.StripeBillingState{
- CustomerID: state.StripeCustomerID.String,
- SubscriptionID: state.StripeSubscriptionID.String,
- LicenseKey: state.LicenseKey.String,
+ CustomerID: state.StripeCustomerID.String,
+ SubscriptionID: state.StripeSubscriptionID.String,
+ LicenseKey: state.LicenseKey.String,
+ PaddleSubscriptionID: state.PaddleSubscriptionID.String,
}
return nil
})
diff --git a/migrations/202511251500_remove_paddle_trial_columns.sql b/migrations/202511251500_remove_paddle_trial_columns.sql
index 61d71a224..52513a12f 100644
--- a/migrations/202511251500_remove_paddle_trial_columns.sql
+++ b/migrations/202511251500_remove_paddle_trial_columns.sql
@@ -1,6 +1,11 @@
-- Remove Paddle and trial-related columns from tenants_billing
--- We're moving to Stripe-only billing with no trial periods
+-- Keep paddle_subscription_id to identify customers who need to migrate to Stripe
+-- Make paddle_subscription_id nullable (was NOT NULL from 202109072130 migration)
-ALTER TABLE tenants_billing DROP COLUMN IF EXISTS paddle_subscription_id;
ALTER TABLE tenants_billing DROP COLUMN IF EXISTS paddle_plan_id;
ALTER TABLE tenants_billing DROP COLUMN IF EXISTS trial_ends_at;
+
+-- Make paddle_subscription_id nullable so new Stripe subscriptions don't fail
+ALTER TABLE tenants_billing ALTER COLUMN paddle_subscription_id DROP NOT NULL;
+
+-- NOTE: paddle_subscription_id is intentionally kept for migration tracking
diff --git a/public/pages/Administration/pages/ManageBilling.page.tsx b/public/pages/Administration/pages/ManageBilling.page.tsx
index 503181739..08bda8de1 100644
--- a/public/pages/Administration/pages/ManageBilling.page.tsx
+++ b/public/pages/Administration/pages/ManageBilling.page.tsx
@@ -4,6 +4,7 @@ import { HStack, VStack } from "@fider/components/layout"
import { AdminPageContainer } from "../components/AdminBasePage"
import { http } from "@fider/services"
import IconCheck from "@fider/assets/images/heroicons-check.svg"
+import IconInfo from "@fider/assets/images/heroicons-information-circle.svg"
import "./ManageBilling.page.scss"
@@ -11,6 +12,7 @@ interface ManageBillingPageProps {
stripeCustomerID: string
stripeSubscriptionID: string
licenseKey: string
+ paddleSubscriptionID: string
isCommercial: boolean
}
@@ -73,9 +75,39 @@ const PlanCard = (props: PlanCardProps) => {
)
}
+interface PaddleMigrationBannerProps {
+ onUpgradeClick: () => void
+ isLoading: boolean
+}
+
+const PaddleMigrationBanner = (props: PaddleMigrationBannerProps) => {
+ return (
+ <div className="bg-blue-50 p-4 rounded mb-6 border border-blue-200">
+ <HStack spacing={2} align="start">
+ <Icon sprite={IconInfo} className="text-blue-600 flex-shrink-0 mt-0.5" height="20" />
+ <VStack spacing={1}>
+ <p className="text-sm text-gray-900 text-medium">Migration to Stripe Billing</p>
+ <p className="text-sm text-gray-700">
+ You're currently entitled to pro features because of your existing subscription.
+ <br />
+ <a onClick={props.onUpgradeClick} className="clickable text-blue-600">
+ {props.isLoading ? "Loading..." : "Switch to our new Stripe billing instead and save money"}
+ </a>
+ </p>
+ </VStack>
+ </HStack>
+ </div>
+ )
+}
+
const ManageBillingPage = (props: ManageBillingPageProps) => {
const [isLoading, setIsLoading] = useState(false)
- const isCommercial = props.isCommercial
+
+ // Detect Paddle customers who need to migrate
+ const isPaddleCustomer = Boolean(props.paddleSubscriptionID && !props.stripeSubscriptionID && props.isCommercial)
+
+ // Display as commercial only if they're truly a Stripe customer
+ const displayAsCommercial = props.isCommercial && !isPaddleCustomer
const openPortal = async () => {
setIsLoading(true)
@@ -105,10 +137,16 @@ const ManageBillingPage = (props: ManageBillingPageProps) => {
<AdminPageContainer id="p-admin-billing" name="billing" title="Billing" subtitle="Manage your subscription and billing">
<p>Fider is free forever. But if you need advanced features and support, consider upgrading to Pro.</p>
- {isCommercial && props.licenseKey && (
+ {isPaddleCustomer && <PaddleMigrationBanner onUpgradeClick={startCheckout} isLoading={isLoading} />}
+
+ {displayAsCommercial && props.licenseKey && (
<div className="bg-blue-50 p-4 rounded mb-4 border border-blue-200">
<p className="text-sm text-gray-700">
- If you want to run Fider self-hosted with commercial features, <a href="/admin/advanced" className="text-blue-600 hover:text-blue-800 underline">see advanced</a>.
+ If you want to run Fider self-hosted with commercial features,{" "}
+ <a href="/admin/advanced" className="text-blue-600 hover:text-blue-800 underline">
+ see advanced
+ </a>
+ .
</p>
</div>
)}
@@ -120,11 +158,11 @@ const ManageBillingPage = (props: ManageBillingPageProps) => {
period="month"
description="Perfect for getting started with feedback collection."
features={freeFeatures}
- isCurrent={!isCommercial}
+ isCurrent={!displayAsCommercial}
buttonText="Downgrade"
buttonVariant="secondary"
- onButtonClick={isCommercial ? openPortal : undefined}
- isLoading={isLoading && isCommercial}
+ onButtonClick={displayAsCommercial ? openPortal : undefined}
+ isLoading={isLoading && displayAsCommercial}
/>
<PlanCard
@@ -133,11 +171,11 @@ const ManageBillingPage = (props: ManageBillingPageProps) => {
period="month"
description="For teams that need advanced features and support."
features={proFeatures}
- isCurrent={isCommercial}
+ isCurrent={displayAsCommercial}
isHighlighted={true}
- buttonText={isCommercial ? "Manage Billing" : "Upgrade to Pro"}
+ buttonText={displayAsCommercial ? "Manage Billing" : "Upgrade to Pro"}
buttonVariant="primary"
- onButtonClick={isCommercial ? openPortal : startCheckout}
+ onButtonClick={displayAsCommercial ? openPortal : startCheckout}
isLoading={isLoading}
/>
</div>