Skip to content

Commit

Permalink
feat: Try new stripe Pricing Table (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
storm1729 committed Jul 1, 2024
1 parent 15bcbd0 commit 82bf026
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/[lang]/pricing/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export function ProductCard({
const d = props.d.pricing;

const active = !!subscription;
console.log("AAA", product.prices);
const price = product.prices.find(({ currency: c }) => currency === c);
// For the SAA10k and SaaS100k products, we also allow a yearly subscription.
// This is currently not implemented in the UI, but the backend supports it.
const price = product.prices.find(
({ currency: c, interval }) => currency === c && interval === "month"
);
if (!price || !price.unit_amount) {
return <p>Error: No price found for product {product.id}.</p>;
}
Expand Down
20 changes: 20 additions & 0 deletions src/app/[lang]/pricing_new/StripePricingTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

import React, { useEffect } from "react";

export const StripePricingTable = () => {
useEffect(() => {
const script = document.createElement("script");
script.src = "https://js.stripe.com/v3/pricing-table.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, []);

return React.createElement("stripe-pricing-table", {
"pricing-table-id": "prctbl_1OOqJhA852XqldwXWBnBH1qL",
"publishable-key": "pk_live_O6JxAuRV03zH5EC0V2aEqD1F00PqJvtIsb",
});
};
36 changes: 36 additions & 0 deletions src/app/[lang]/pricing_new/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Spacer, Text } from "@/components/Geist";
import React from "react";
import { dictionary } from "@/dictionaries";
import { Nav } from "@/components/Nav/Nav";
import { Footer } from "@/components/Footer";
import { StripePricingTable } from "./StripePricingTable";

export const metadata = {
title: "Pricing",
};

export default async function Pricing({
params: { lang },
}: {
params: { lang: string };
}) {
const d = await dictionary(lang);

return (
<>
<Nav d={d} />
<Spacer h={5} />
<Text className="text-center" h2>
{d.pricing.title}
</Text>
<Text p em className="text-center">
{d.pricing["30d_money_back"]}
</Text>

<Spacer h={2} />

<StripePricingTable />
<Footer d={d} />
</>
);
}

0 comments on commit 82bf026

Please sign in to comment.