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/get-stripe-publishable-key.ts
Views: 791
1
// Not part of customize because its rare to need this -- only when actually making
2
// an explicit purchase.
3
4
import getAccountId from "lib/account/get-account";
5
import { getServerSettings } from "@cocalc/database/settings/server-settings";
6
7
export default async function handle(req, res) {
8
try {
9
res.json(await get(req));
10
} catch (err) {
11
res.json({ error: `${err.message}` });
12
return;
13
}
14
}
15
16
async function get(req) {
17
const account_id = await getAccountId(req);
18
if (account_id == null) {
19
throw Error("must be signed in");
20
}
21
const { stripe_publishable_key } = await getServerSettings();
22
return { stripe_publishable_key };
23
}
24
25