Path: blob/master/src/packages/next/pages/api/v2/purchases/renew-subscription.ts
1454 views
/*1Renew one of your subscriptions. Returns {purchase_id:number|nill} for the purchase of the next interval of the subscription.2Null if nothing needed to be done.3*/45import getAccountId from "lib/account/get-account";6import getParams from "lib/api/get-params";7import renewSubscription from "@cocalc/server/purchases/renew-subscription";89export default async function handle(req, res) {10try {11res.json(await get(req));12} catch (err) {13res.json({ error: `${err.message}` });14return;15}16}1718async function get(req) {19const account_id = await getAccountId(req);20if (account_id == null) {21throw Error("must be signed in");22}23const { subscription_id } = getParams(req);24return {25purchase_id: await renewSubscription({26account_id,27subscription_id,28}),29};30}313233