Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

wip

Kiran K14203137d74e
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
index ba5de518bf..f973625624 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
@@ -1,3 +1,4 @@
+import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
import { prisma } from "@dub/prisma";
import {
@@ -23,7 +24,17 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
});
if (invoice.workspaceId !== workspace.id) {
- return new Response("Unauthorized", { status: 403 });
+ throw new DubApiError({
+ code: "unauthorized",
+ message: "You are not authorized to view this invoice",
+ });
+ }
+
+ if (invoice.status !== "completed") {
+ throw new DubApiError({
+ code: "unprocessable_entity",
+ message: "You can download the invoice once it is completed.",
+ });
}
const pdf = await renderToBuffer(
diff --git a/apps/web/lib/pdf/templates/payout-invoice.tsx b/apps/web/lib/pdf/templates/payout-invoice.tsx
new file mode 100644
index 0000000000..e69de29bb2