CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/billing/get-invoice.ts
Views: 687
1
/*
2
Get specific invoice, given that you know the invoice id.
3
We do NOT make any requirement that you are the user that
4
created the invoice. The invoice id's seem pretty long and
5
random, so this should be OK.
6
*/
7
import { getInvoice } from "@cocalc/server/billing/get-invoices-and-receipts";
8
import getAccountId from "lib/account/get-account";
9
import getParams from "lib/api/get-params";
10
11
export default async function handle(req, res) {
12
try {
13
res.json(await get(req));
14
} catch (err) {
15
res.json({ error: `${err.message}` });
16
return;
17
}
18
}
19
20
async function get(req): Promise<object> {
21
const account_id = await getAccountId(req);
22
if (account_id == null) {
23
throw Error("must be signed in");
24
}
25
const { invoice_id } = getParams(req);
26
return await getInvoice(invoice_id);
27
}
28
29