Path: blob/master/src/packages/next/pages/api/v2/billing/get-invoice-url.ts
1451 views
/*1Get specific invoice's hosted URL, given that you know the invoice id.23LEGACY: Also works for receipt of payment intent.4*/5import { getInvoiceUrl } from "@cocalc/server/billing/get-invoices-and-receipts";6import getAccountId from "lib/account/get-account";7import getParams from "lib/api/get-params";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): Promise<object> {19const account_id = await getAccountId(req);20if (account_id == null) {21// doesn't matter what id is -- just that signed in...22throw Error("must be signed in");23}24const { invoice_id } = getParams(req);25return { url: await getInvoiceUrl(invoice_id) };26}272829