Path: blob/master/src/packages/next/pages/api/v2/purchases/stripe/get-checkout-session.ts
1456 views
import getAccountId from "lib/account/get-account";1import getCheckoutSession from "@cocalc/server/purchases/stripe/get-checkout-session";2import throttle from "@cocalc/util/api/throttle";3import getParams from "lib/api/get-params";45export default async function handle(req, res) {6try {7res.json(await get(req));8} catch (err) {9res.json({ error: `${err.message}` });10return;11}12}1314async function get(req) {15const account_id = await getAccountId(req);16if (account_id == null) {17throw Error("must be signed in");18}19throttle({ account_id, endpoint: "purchases/stripe/get-checkout-session" });2021const { purpose, description, lineItems, return_url, metadata } =22getParams(req);2324return await getCheckoutSession({25account_id,26purpose,27description,28lineItems,29return_url,30metadata,31});32}333435