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. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/purchases/stripe/create-setup-intent.ts
Views: 791
1
import getAccountId from "lib/account/get-account";
2
import createSetupIntent from "@cocalc/server/purchases/stripe/create-setup-intent";
3
import getParams from "lib/api/get-params";
4
import throttle from "@cocalc/util/api/throttle";
5
6
export default async function handle(req, res) {
7
try {
8
res.json(await get(req));
9
} catch (err) {
10
res.json({ error: `${err.message}` });
11
return;
12
}
13
}
14
15
async function get(req) {
16
const account_id = await getAccountId(req);
17
if (account_id == null) {
18
throw Error("must be signed in");
19
}
20
throttle({ account_id, endpoint: "purchases/stripe/create-setup-intent" });
21
const { description } = getParams(req);
22
return await createSetupIntent({
23
account_id,
24
description,
25
});
26
}
27
28