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