Packages paid through Stripe Checkout
The catalog stays in packages.rs: every checkout session carries the package's name and gross price, nothing has to be kept in Stripe. The package is granted once, when Stripe confirms the payment: by the signed webhook, or by the return page asking Stripe when the webhook is late. With a test key only admins can buy, so Stripe's test cards give nobody free packages. Without the keys nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -6,7 +6,16 @@ import type { NextRequest } from "next/server";
|
||||
import { BACKEND_URL } from "@/lib/server";
|
||||
import { SHARES_TAG } from "@/lib/share";
|
||||
|
||||
const REQUEST_HEADERS = ["accept", "accept-language", "authorization", "content-type", "cookie", "user-agent"];
|
||||
// stripe-signature: Stripe's webhook (the body is passed on byte for byte).
|
||||
const REQUEST_HEADERS = [
|
||||
"accept",
|
||||
"accept-language",
|
||||
"authorization",
|
||||
"content-type",
|
||||
"cookie",
|
||||
"stripe-signature",
|
||||
"user-agent",
|
||||
];
|
||||
// Hop-by-hop or re-computed by the runtime.
|
||||
const SKIP_RESPONSE_HEADERS = new Set(["connection", "content-encoding", "content-length", "set-cookie", "transfer-encoding"]);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { Metadata } from "next";
|
||||
import { AiNote } from "@/components/AiNote";
|
||||
import { PackageCards } from "@/components/PackageCards";
|
||||
import { RedeemCode } from "@/components/RedeemCode";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Package, PublicConfig } from "@/lib/types";
|
||||
|
||||
@@ -39,7 +40,7 @@ export default async function PackagesPage() {
|
||||
backendGet<PublicConfig>("/v1/config"),
|
||||
]);
|
||||
const packages = catalog?.packages ?? [];
|
||||
const canPay = config?.mock_payments ?? false;
|
||||
const canPay = payMethod(config, me);
|
||||
const left = me.analyses_left;
|
||||
const slots = me.persons;
|
||||
|
||||
|
||||
@@ -948,3 +948,12 @@ a.pair-row:hover strong { color: var(--gold); }
|
||||
/* Chart page: below the wheel and the summary, the facts and the next steps side by side */
|
||||
.chart-extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: stretch; }
|
||||
.chart-extras > .card { margin: 0; }
|
||||
|
||||
/* Back from Stripe: the payment's result at the bottom of the screen. */
|
||||
.pay-return { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; width: min(560px, calc(100% - 32px)); }
|
||||
.pay-return .msg {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 14px 16px;
|
||||
background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.pay-return .msg-ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
|
||||
.pay-return .msg-error { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ChartWheel } from "@/components/ChartWheel";
|
||||
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
|
||||
import { ForecastKeys, ForecastTimeline, ForecastTransits, longDay } from "@/components/ForecastViews";
|
||||
import { Tabs } from "@/components/Tabs";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Analysis, Chart, ForecastDetail, ForecastList, PublicConfig } from "@/lib/types";
|
||||
|
||||
@@ -134,7 +135,7 @@ export default async function ForecastPage({
|
||||
initial={detailed}
|
||||
left={me.analyses_left.forecast}
|
||||
isAdmin={me.user.roles.includes("admin")}
|
||||
canPay={config?.mock_payments ?? false}
|
||||
canPay={payMethod(config, me)}
|
||||
questionsLeft={me.analyses_left.question ?? 0}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
||||
import { CompareButton } from "@/components/CompareButton";
|
||||
import { Tabs } from "@/components/Tabs";
|
||||
import { ASPECTS, ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Analysis, Chart, ChartListItem, PublicConfig } from "@/lib/types";
|
||||
|
||||
@@ -181,7 +182,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
initial={detailed}
|
||||
left={me.analyses_left.natal}
|
||||
isAdmin={me.user.roles.includes("admin")}
|
||||
canPay={config?.mock_payments ?? false}
|
||||
canPay={payMethod(config, me)}
|
||||
questionsLeft={me.analyses_left.question ?? 0}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Cormorant_Garamond, Inter } from "next/font/google";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import { PaymentReturn } from "@/components/PaymentReturn";
|
||||
import { SiteHeader } from "@/components/SiteHeader";
|
||||
import { getMe } from "@/lib/server";
|
||||
|
||||
@@ -25,6 +27,11 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
<body>
|
||||
{me && <SiteHeader me={me} />}
|
||||
{children}
|
||||
{me && (
|
||||
<Suspense fallback={null}>
|
||||
<PaymentReturn />
|
||||
</Suspense>
|
||||
)}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CompositeTables, CrossGrid, HouseOverlays, InterAspectList, NatureBar }
|
||||
import { SynastryLegend, SynastryWheel } from "@/components/SynastryWheel";
|
||||
import { Tabs } from "@/components/Tabs";
|
||||
import { ASPECTS, formatBirthDate } from "@/lib/astro";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import { sideName, sideTimeKnown } from "@/lib/synastry";
|
||||
import type { Analysis, ChartListItem, PublicConfig, Synastry, SynastrySide } from "@/lib/types";
|
||||
@@ -127,7 +128,7 @@ export default async function ComparisonPage({ params }: { params: Promise<{ id:
|
||||
initial={detailed}
|
||||
left={me.analyses_left.synastry}
|
||||
isAdmin={me.user.roles.includes("admin")}
|
||||
canPay={config?.mock_payments ?? false}
|
||||
canPay={payMethod(config, me)}
|
||||
note={`Az elemzésben az első fél: ${name1}, a második fél: ${name2}.`}
|
||||
questionsLeft={me.analyses_left.question ?? 0}
|
||||
/>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ChartCard } from "@/components/ChartCard";
|
||||
import { PersonActions } from "@/components/PersonActions";
|
||||
import { PendingInvites } from "@/components/PendingInvites";
|
||||
import { PersonPacks } from "@/components/PersonPacks";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { ChartListItem, PublicConfig } from "@/lib/types";
|
||||
|
||||
@@ -102,7 +103,7 @@ export default async function PersonsPage() {
|
||||
? "Elfogytak a helyeid. Újabb személyhez válassz csomagot."
|
||||
: "A felvett személyek képletét és elemzéseit itt éred el. Egy törölt személy helye nem szabadul fel."}
|
||||
</p>
|
||||
<PersonPacks canPay={config?.mock_payments ?? false} />
|
||||
<PersonPacks canPay={payMethod(config, me)} />
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
import { PersonPacks } from "@/components/PersonPacks";
|
||||
import { payMethod } from "@/lib/payments";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { PublicConfig } from "@/lib/types";
|
||||
|
||||
@@ -31,7 +32,7 @@ export default async function NewPersonPage() {
|
||||
full={
|
||||
<>
|
||||
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot, vagy hívd meg.</p>
|
||||
<PersonPacks canPay={config?.mock_payments ?? false} />
|
||||
<PersonPacks canPay={payMethod(config, me)} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user