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/purchases/sync-paid-invoices.ts
Views: 687
1
/*
2
Let user get all of their purchase quotas.
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import syncPaidInvoices from "@cocalc/server/purchases/sync-paid-invoices";
7
import { OkStatus } from "lib/api/status";
8
9
export default async function handle(req, res) {
10
try {
11
res.json(await get(req));
12
} catch (err) {
13
res.json({ error: `${err.message}` });
14
return;
15
}
16
}
17
18
async function get(req) {
19
const account_id = await getAccountId(req);
20
if (account_id == null) {
21
throw Error("must be signed in");
22
}
23
const count = await syncPaidInvoices(account_id);
24
return {
25
...OkStatus,
26
count,
27
};
28
}
29
30