cancel subscription on account deletion
This commit is contained in:
@ -2,6 +2,7 @@ import { Queue } from "quirrel/blitz";
|
||||
|
||||
import db, { MembershipRole } from "../../../../db";
|
||||
import appLogger from "../../../../integrations/logger";
|
||||
import { cancelPaddleSubscription } from "../../../../integrations/paddle";
|
||||
|
||||
const logger = appLogger.child({ queue: "delete-user-data" });
|
||||
|
||||
@ -16,7 +17,7 @@ const deleteUserData = Queue<Payload>("api/queue/delete-user-data", async ({ use
|
||||
memberships: {
|
||||
include: {
|
||||
organization: {
|
||||
include: { memberships: { include: { user: true } } },
|
||||
include: { subscription: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -31,6 +32,11 @@ const deleteUserData = Queue<Payload>("api/queue/delete-user-data", async ({ use
|
||||
const organization = user.memberships[0]!.organization;
|
||||
await db.organization.delete({ where: { id: organization.id } });
|
||||
await db.user.delete({ where: { id: user.id } });
|
||||
|
||||
if (organization.subscription) {
|
||||
await cancelPaddleSubscription({ subscriptionId: organization.subscription.paddleSubscriptionId });
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case MembershipRole.USER: {
|
||||
|
@ -53,7 +53,7 @@ export default function BillingHistory() {
|
||||
{payment.amount} {payment.currency}
|
||||
</td>
|
||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{payment.is_paid === 1 ? "Paid" : "Not paid yet"}
|
||||
{payment.is_paid === 1 ? "Paid" : "Upcoming"}
|
||||
</td>
|
||||
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
{typeof payment.receipt_url !== "undefined" ? (
|
||||
|
@ -10,7 +10,10 @@ export default function Plans() {
|
||||
return (
|
||||
<div className="mt-6 flex flex-row-reverse flex-wrap-reverse gap-x-4">
|
||||
{pricing.tiers.map((tier) => {
|
||||
const isCurrentTier = subscription?.paddlePlanId === tier.planId;
|
||||
const isCurrentTier =
|
||||
!subscription?.paddlePlanId && tier.planId === "free"
|
||||
? true
|
||||
: subscription?.paddlePlanId === tier.planId;
|
||||
const cta = isCurrentTier ? "Current plan" : !!subscription ? `Switch to ${tier.title}` : "Subscribe";
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user