"use strict";
(() => {
var exports = {};
exports.id = 3962;
exports.ids = [3962];
exports.modules = {

/***/ 439491:
/***/ ((module) => {

module.exports = require("assert");

/***/ }),

/***/ 714300:
/***/ ((module) => {

module.exports = require("buffer");

/***/ }),

/***/ 532081:
/***/ ((module) => {

module.exports = require("child_process");

/***/ }),

/***/ 435001:
/***/ ((module) => {

module.exports = require("cluster");

/***/ }),

/***/ 722057:
/***/ ((module) => {

module.exports = require("constants");

/***/ }),

/***/ 706113:
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),

/***/ 809523:
/***/ ((module) => {

module.exports = require("dns");

/***/ }),

/***/ 582361:
/***/ ((module) => {

module.exports = require("events");

/***/ }),

/***/ 657147:
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ 773292:
/***/ ((module) => {

module.exports = require("fs/promises");

/***/ }),

/***/ 113685:
/***/ ((module) => {

module.exports = require("http");

/***/ }),

/***/ 795687:
/***/ ((module) => {

module.exports = require("https");

/***/ }),

/***/ 241808:
/***/ ((module) => {

module.exports = require("net");

/***/ }),

/***/ 822037:
/***/ ((module) => {

module.exports = require("os");

/***/ }),

/***/ 371017:
/***/ ((module) => {

module.exports = require("path");

/***/ }),

/***/ 504074:
/***/ ((module) => {

module.exports = require("perf_hooks");

/***/ }),

/***/ 677282:
/***/ ((module) => {

module.exports = require("process");

/***/ }),

/***/ 514521:
/***/ ((module) => {

module.exports = require("readline");

/***/ }),

/***/ 12781:
/***/ ((module) => {

module.exports = require("stream");

/***/ }),

/***/ 371576:
/***/ ((module) => {

module.exports = require("string_decoder");

/***/ }),

/***/ 924404:
/***/ ((module) => {

module.exports = require("tls");

/***/ }),

/***/ 76224:
/***/ ((module) => {

module.exports = require("tty");

/***/ }),

/***/ 257310:
/***/ ((module) => {

module.exports = require("url");

/***/ }),

/***/ 473837:
/***/ ((module) => {

module.exports = require("util");

/***/ }),

/***/ 984655:
/***/ ((module) => {

module.exports = require("v8");

/***/ }),

/***/ 959796:
/***/ ((module) => {

module.exports = require("zlib");

/***/ }),

/***/ 124424:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ handle)
/* harmony export */ });
/* harmony import */ var _cocalc_server_billing_get_invoices_and_receipts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(125130);
/* harmony import */ var lib_account_get_account__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(559459);
/*
Get invoices and receipts for the given user.
*/ 

async function handle(req, res) {
    try {
        res.json(await get(req));
    } catch (err) {
        res.json({
            error: `${err.message}`
        });
        return;
    }
}
async function get(req) {
    const account_id = await (0,lib_account_get_account__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(req);
    if (account_id == null) {
        return {};
    }
    return await (0,_cocalc_server_billing_get_invoices_and_receipts__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)(account_id);
}


/***/ }),

/***/ 125130:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

var __webpack_unused_export__;

__webpack_unused_export__ = ({ value: true });
const client_1 = __webpack_require__(946911);
const misc_1 = __webpack_require__(854006);
async function getInvoicesAndReceipts(account_id) {
    if (!(0, misc_1.isValidUUID)(account_id)) {
        throw Error("invalid uuid");
    }
    const stripe = new client_1.StripeClient({ account_id });
    if (!(await stripe.get_customer_id())) {
        return {};
    }
    const mesg = await stripe.mesg_get_invoices({});
    return mesg.invoices;
}
exports.Z = getInvoicesAndReceipts;
//# sourceMappingURL=get-invoices-and-receipts.js.map

/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../../webpack-api-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [6918,1199,8180,2921,9557,5245,6652,6942,5517,6099,5751,2739,9295,8759,2003,1808,4006,8312,5710,9459,4181,4557,7896,6177,7710,7877,6911], () => (__webpack_exec__(124424)));
module.exports = __webpack_exports__;

})();