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/get-checkout-session.ts
Views: 791
1
import getAccountId from "lib/account/get-account";
2
import getCheckoutSession from "@cocalc/server/purchases/stripe/get-checkout-session";
3
import throttle from "@cocalc/util/api/throttle";
4
import getParams from "lib/api/get-params";
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/get-checkout-session" });
21
22
const { purpose, description, lineItems, return_url, metadata } =
23
getParams(req);
24
25
return await getCheckoutSession({
26
account_id,
27
purpose,
28
description,
29
lineItems,
30
return_url,
31
metadata,
32
});
33
}
34
35