Skip to content

Commit df1f150

Browse files
authored
Merge pull request #21 from eersnington/polar-to-dodopayments
Polar to dodopayments
2 parents 55c258d + a6f519b commit df1f150

35 files changed

+741
-790
lines changed

apps/web/.env.example

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
RESEND_API_KEY="re_"
33
RESEND_SENDER_EMAIL_AUTH="[email protected]"
44

5-
# Polar
6-
POLAR_ORGANIZATION_TOKEN=""
7-
POLAR_WEBHOOK_SECRET=""
8-
POLAR_ENVIRONMENT="sandbox"
9-
105
# Databuddy Analytics
116
NEXT_PUBLIC_DATABUDDY_CLIENT_ID=""
127

apps/web/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
"start": "next start"
99
},
1010
"dependencies": {
11-
"@diff0/analytics": "workspace:*",
1211
"@diff0/ai": "workspace:*",
12+
"@diff0/analytics": "workspace:*",
1313
"@diff0/backend": "workspace:*",
1414
"@diff0/sandbox": "workspace:*",
1515
"@hookform/resolvers": "^5.2.2",
16-
"@polar-sh/nextjs": "^0.4.9",
17-
"@polar-sh/sdk": "^0.35.4",
1816
"@radix-ui/react-accordion": "^1.2.12",
1917
"@radix-ui/react-alert-dialog": "^1.1.15",
2018
"@radix-ui/react-aspect-ratio": "^1.1.7",

apps/web/src/app/(dashboard)/billing/billing-content.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client";
22

3-
import { api } from "@diff0/backend/convex/_generated/api";
3+
import type { api } from "@diff0/backend/convex/_generated/api";
44
import { authClient } from "@diff0/backend/lib/auth-client";
55
import type { Preloaded } from "convex/react";
6-
import { useAction, usePreloadedQuery } from "convex/react";
6+
import { usePreloadedQuery } from "convex/react";
77
import { Beaker, CreditCard, Loader2, TrendingUp } from "lucide-react";
88
import Link from "next/link";
99
import { useState } from "react";
@@ -61,17 +61,13 @@ export function BillingContent({ preloadedBillingData }: BillingContentProps) {
6161
day: "numeric",
6262
});
6363

64-
const ensurePolarCustomer = useAction(api.polarHelpers.ensurePolarCustomer);
65-
6664
const handlePurchase = async (slug: string) => {
6765
setLoadingSlug(slug);
6866
toast.loading("Just a sec", {
6967
description: "Consulting the Orb 🔮 to summon your user essence...",
7068
});
7169
try {
72-
await ensurePolarCustomer();
73-
74-
await authClient.checkout({
70+
await authClient.dodopayments.checkout({
7571
slug,
7672
});
7773
} catch (_error) {
@@ -238,7 +234,7 @@ export function BillingContent({ preloadedBillingData }: BillingContentProps) {
238234
))}
239235
</div>
240236
<p className="mt-4 text-muted-foreground text-sm">
241-
Payment processing via Polar. Credits expire in 1 year.
237+
Payment processing via Dodopayments. Credits expire in 1 year.
242238
</p>
243239
</CardContent>
244240
</Card>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Skeleton } from "@/components/ui/skeleton";
22

33
export default function Loading() {
4-
return <Skeleton className="flex h-full m-2" />
4+
return <Skeleton className="m-2 flex h-full" />;
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Skeleton } from "@/components/ui/skeleton";
22

33
export default function Loading() {
4-
return <Skeleton className="flex h-full m-2" />
4+
return <Skeleton className="m-2 flex h-full" />;
55
}

apps/web/src/app/(dashboard)/billing/success/success-content.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ const CENTS_TO_CURRENCY_UNIT = 100;
1818

1919
export function SuccessContent() {
2020
const searchParams = useSearchParams();
21-
const checkoutId = searchParams.get("checkout_id");
21+
const paymentId = searchParams.get("payment_id");
2222

23-
const checkoutDetails = useQuery(
24-
api.polar.queries.getCheckoutDetails,
25-
checkoutId ? { checkoutId } : "skip"
23+
const paymentDetails = useQuery(
24+
api.payments.queries.getPaymentDetails,
25+
paymentId ? { paymentId } : "skip"
2626
);
2727

28-
if (!checkoutId) {
28+
if (!paymentId) {
2929
return (
3030
<Card className="w-full max-w-md">
3131
<CardHeader className="text-center">
3232
<CardTitle className="text-2xl">Invalid Request</CardTitle>
33-
<CardDescription>
34-
No checkout ID provided in the URL
35-
</CardDescription>
33+
<CardDescription>No payment ID provided in the URL</CardDescription>
3634
</CardHeader>
3735
<CardContent>
3836
<Button asChild className="w-full">
@@ -43,7 +41,7 @@ export function SuccessContent() {
4341
);
4442
}
4543

46-
if (checkoutDetails === undefined) {
44+
if (paymentDetails === undefined) {
4745
return (
4846
<Card className="w-full max-w-md">
4947
<CardHeader className="text-center">
@@ -59,13 +57,13 @@ export function SuccessContent() {
5957
);
6058
}
6159

62-
if (!checkoutDetails) {
60+
if (!paymentDetails) {
6361
return (
6462
<Card className="w-full max-w-md">
6563
<CardHeader className="text-center">
6664
<CardTitle className="text-2xl">Order Not Found</CardTitle>
6765
<CardDescription>
68-
We couldn't find an order with this checkout ID
66+
We couldn't find an order with this payment ID
6967
</CardDescription>
7068
</CardHeader>
7169
<CardContent>
@@ -77,7 +75,7 @@ export function SuccessContent() {
7775
);
7876
}
7977

80-
const { order, credits } = checkoutDetails;
78+
const { order, credits } = paymentDetails;
8179

8280
return (
8381
<Card className="w-full max-w-md">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Skeleton } from "@/components/ui/skeleton";
22

33
export default function Loading() {
4-
return <Skeleton className="flex h-full m-2" />
4+
return <Skeleton className="m-2 flex h-full" />;
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Skeleton } from "@/components/ui/skeleton";
22

33
export default function Loading() {
4-
return <Skeleton className="flex h-full m-2" />
4+
return <Skeleton className="m-2 flex h-full" />;
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Skeleton } from "@/components/ui/skeleton";
22

33
export default function Loading() {
4-
return <Skeleton className="flex h-full m-2" />
4+
return <Skeleton className="m-2 flex h-full" />;
55
}

0 commit comments

Comments
 (0)