Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/api/src/controllers/merchant/billing.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ export const MerchantBillingController = {
};
format = (d) =>
d.toLocaleTimeString([], { hour: "2-digit", hour12: false }) + ":00";
} else if (period === "90d") {
startTime = new Date(now.getTime() - 90 * 24 * 60 * 60 * 1000);
groupBy = { $dateToString: { format: "%Y-%m-%d", date: "$createdAt" } };
format = (d) =>
d.toLocaleDateString([], { month: "short", day: "numeric" });
} else if (period === "30d") {
startTime = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
groupBy = { $dateToString: { format: "%Y-%m-%d", date: "$createdAt" } };
Expand Down Expand Up @@ -214,7 +219,8 @@ export const MerchantBillingController = {

// Fill in zeros for missing periods to ensure smooth chart
const chartData: { name: string; volume: number }[] = [];
const steps = period === "24h" ? 24 : period === "30d" ? 30 : 7;
const steps =
period === "24h" ? 24 : period === "90d" ? 90 : period === "30d" ? 30 : 7;
const stepMs = period === "24h" ? 3600000 : 86400000;

for (let i = 0; i < steps; i++) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/merchants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export async function merchantRoutes(app: FastifyInstance) {
preHandler: requireAuth,
schema: {
querystring: z.object({
period: z.enum(["24h", "7d", "30d"]).default("7d"),
period: z.enum(["24h", "7d", "30d", "90d"]).default("7d"),
}),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function CheckoutPageClient({
(data: {
status: string;
confirmations: number;
txHash: string;
txHash: string | null;
cryptoAmountReceived?: number;
}) => {
setInvoice((prev) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/checkout/src/app/checkout/[invoiceId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export async function generateMetadata({
description: `Amount: ${amount}. Pay securely with crypto via KnotEngine.`,
images: invoice.merchant?.logo_url
? [invoice.merchant.logo_url]
: ["/og-image-checkout.png"],
: undefined,
},
twitter: {
card: "summary",
title: `Pay ${merchantName}`,
description: `Securely send ${amount} in crypto.`,
images: invoice.merchant?.logo_url
? [invoice.merchant.logo_url]
: ["/og-image-checkout.png"],
: undefined,
},
};
}
Expand Down
9 changes: 0 additions & 9 deletions apps/checkout/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,11 @@ export const metadata: Metadata = {
siteName: "KnotEngine Checkout",
title: "KnotEngine | Secure Crypto Checkout",
description: "Accept crypto payments directly into your own wallet.",
images: [
{
url: "/og-image-checkout.png",
width: 1200,
height: 630,
alt: "KnotEngine Secure Checkout",
},
],
},
twitter: {
card: "summary_large_image",
title: "KnotEngine | Secure Crypto Checkout",
description: "Accept crypto payments directly into your own wallet.",
images: ["/og-image-checkout.png"],
creator: "@knotengine",
},
};
Expand Down
34 changes: 4 additions & 30 deletions apps/checkout/src/components/CheckoutCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,10 @@ import { QRCodeSVG } from "qrcode.react";
import { Copy, Check, Clock, AlertCircle, Wallet } from "lucide-react";
import { cn } from "@/lib/utils";
import { CRYPTO_LOGOS, Currency } from "@qodinger/knot-types";
import { Invoice } from "@/types/invoice";

interface CheckoutCardProps {
invoice: {
invoice_id: string;
amount_usd: number;
crypto_amount: number;
crypto_amount_received?: number;
crypto_currency: string;
pay_address: string;
status: string;
expires_at: string;
fee_usd: number;
metadata?: {
isTestnet?: boolean;
feeResponsibility?: "client" | "merchant";
};
merchant?: {
name: string;
logo_url?: string | null;
return_url?: string | null;
theme?: "light" | "dark" | "system";
brand_color?: string;
branding_enabled?: boolean;
branding_alignment?: "left" | "center";
remove_branding?: boolean;
bip21_enabled?: boolean;
plan?: "starter" | "professional" | "enterprise";
};
description?: string;
};
invoice: Invoice;
}

export function CheckoutCard({ invoice }: CheckoutCardProps) {
Expand Down Expand Up @@ -278,10 +252,10 @@ export function CheckoutCard({ invoice }: CheckoutCardProps) {
USD
</p>
{invoice.metadata?.feeResponsibility === "client" &&
invoice.fee_usd > 0 &&
(invoice.fee_usd ?? 0) > 0 &&
invoice.status !== "partially_paid" && (
<p className="text-muted-foreground/60 mt-0.5 text-[9px] font-medium tracking-wide uppercase">
Includes ${invoice.fee_usd.toFixed(2)} Platform Fee
Includes ${(invoice.fee_usd ?? 0).toFixed(2)} Platform Fee
</p>
)}
</div>
Expand Down
14 changes: 11 additions & 3 deletions apps/checkout/src/types/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ export interface Invoice {
pay_address: string;
status: string;
expires_at: string;
fee_usd: number;
tx_hash?: string;
fee_usd?: number;
fee_crypto?: number;
tx_hash?: string | null;
confirmations?: number;
required_confirmations?: number;
paid_at?: string | null;
created_at?: string;
metadata?: {
isTestnet?: boolean;
feeResponsibility?: "client" | "merchant";
network?: string;
baseAmountUsd?: number;
};
merchant?: {
name: string;
Expand All @@ -23,7 +29,9 @@ export interface Invoice {
branding_enabled?: boolean;
remove_branding?: boolean;
bip21_enabled?: boolean;
branding_alignment?: "left" | "center";
plan?: "starter" | "professional" | "enterprise";
};
description?: string;
description?: string | null;
checkout_url?: string;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@commitlint/cli": "^20.4.1",
"@commitlint/config-conventional": "^20.4.1",
"@commitlint/config-conventional": "^21.0.1",
"@types/node": "^25.2.3",
"@typescript-eslint/eslint-plugin": "^8.56.0",
"@typescript-eslint/parser": "^8.56.0",
Expand Down
Loading
Loading