Path: blob/master/src/packages/next/pages/api/v2/billing/get-invoice.ts
1452 views
/*1Get specific invoice, given that you know the invoice id.2We do NOT make any requirement that you are the user that3created the invoice. The invoice id's seem pretty long and4random, so this should be OK.5*/6import { getInvoice } from "@cocalc/server/billing/get-invoices-and-receipts";7import getAccountId from "lib/account/get-account";8import getParams from "lib/api/get-params";910export default async function handle(req, res) {11try {12res.json(await get(req));13} catch (err) {14res.json({ error: `${err.message}` });15return;16}17}1819async function get(req): Promise<object> {20const account_id = await getAccountId(req);21if (account_id == null) {22throw Error("must be signed in");23}24const { invoice_id } = getParams(req);25return await getInvoice(invoice_id);26}272829