commit eab403a57f52a941ad4f80f266b90aed3087e449 parent 5cea0b327c97e43b62dca7bb6ed0432d46542b76 Author: Jacob R. Edwards <jacob@jacobedwards.org> Date: Fri, 30 Aug 2024 18:24:19 -0700 Add billing page This page provides access to the Stripe Billing Portal via the floorplan API. Diffstat:
| A | files/settings/billing/index.html | | | 10 | ++++++++++ |
| A | files/settings/billing/main.js | | | 19 | +++++++++++++++++++ |
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/files/settings/billing/index.html b/files/settings/billing/index.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML> +<head> + <title>Spaceplanner - Services</title> + <link rel="stylesheet" type="text/css" href="/css/main.css"> + <script type="module" src="./main.js"></script> + <meta name="viewport" content="width=device-width"> +</head> +<html> + <h1>Manage your subscription</h1> +</html> diff --git a/files/settings/billing/main.js b/files/settings/billing/main.js @@ -0,0 +1,19 @@ +import * as etc from "/lib/etc.js" +import * as api from "/lib/api.js" + +function main() { + if (!api.logged_in()) { + window.location.href = "/login" + } + + api.fetch("POST", "users/" + localStorage.getItem("username") + "/services/billingportal") + .then(function(body) { + window.location.href = body.url + }) + .catch(function(err) { + console.error("Unable to display billing portal:", err) + etc.error("There was an unexpected error.") + }) +} + +main()