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-subscription-payment.ts
Views: 791
1
import getAccountId from "lib/account/get-account";
2
import createSubscriptionPayment from "@cocalc/server/purchases/stripe/create-subscription-payment";
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({
21
account_id,
22
endpoint: "purchases/stripe/create-subscription-payment",
23
});
24
const { subscription_id } = getParams(req);
25
await createSubscriptionPayment({
26
account_id,
27
subscription_id,
28
});
29
return { success: true };
30
}
31
32