Modify the checkout widget to support subscriptions. Add usage-based billing toggle to sharing settings.

This commit is contained in:
Pixeldrain-Server committed 2026-09-30 19:26:21 +02:00
1 parent 4b9434ce0a
commit 7b2e4b4240
25 files changed
+1060 -684

No files matched your search

+4 -3
View File
@@ -3,7 +3,6 @@ import { onMount } from "svelte";
import CopyButton from "layout/CopyButton.svelte";
import { loading_finish, loading_start } from "lib/Loading";
let app_name = $state("")
let api_key = $state("")
const create_key = async () => {
loading_start()
@@ -39,11 +38,13 @@ const toggle_show_key = () => {
}
}
onMount(() => {
let app_name = $derived(() => {
let app = new URL(window.location.href).searchParams.get("app")
if (app) {
app_name = app
consoke.log(app)
return app
}
return null
})
</script>
-125
View File
@@ -1,125 +0,0 @@
<script lang="ts">
import Checkout from "layout/checkout/Checkout.svelte";
import { loading_finish, loading_start } from "lib/Loading";
import { get_endpoint } from "lib/NovaAPI";
import { user } from "lib/UserStore";
import { onMount } from "svelte";
import Euro from "util/Euro.svelte";
import { formatDate } from "util/Formatting";
let invoices = $state([])
let unpaid_invoice = $state(0)
const load_invoices = async () => {
loading_start()
try {
const resp = await fetch(get_endpoint()+"/user/invoice")
if(resp.status >= 400) {
throw new Error((await resp.json()).message)
}
let invoices_tmp = await resp.json()
unpaid_invoice = 0
invoices_tmp.forEach(row => {
row.time = new Date(row.time)
if (row.status === "open") {
unpaid_invoice++
}
})
invoices_tmp.sort((a, b) => {
return b.time - a.time
})
invoices = invoices_tmp
} catch (err) {
console.error(err)
alert(err)
} finally {
loading_finish()
}
};
onMount(() => {
load_invoices()
})
</script>
<section>
<h2 id="deposit">Deposit credit</h2>
<p>
Nova credit can be used for our Prepaid subscription plan, which
is different from the Patreon plans. Instead of monthly limits, with
Prepaid there are no limits. You pay for what you use, at a rate of €4
per TB per month for storage and €1 per TB for data transfer. Your
current account balance is <Euro
amount={$user === null ? 0 : $user.balance_micro_eur}/>
</p>
{#if unpaid_invoice > 1}
<div class="highlight_yellow">
<p>
You still have an unpaid invoice open. Please pay that one
before requesting a new invoice. You can find unpaid
invoices at the bottom of this page. You can cancel an
invoice by clicking Pay, and then clicking the Back link at
the bottom of the page.
</p>
</div>
{:else}
<Checkout/>
{/if}
<h3 id="invoices">Past invoices</h3>
<p>
Invoices are deleted after one year of inactivity.
</p>
<div class="table_scroll">
<table style="text-align: left;">
<thead>
<tr>
<td>ID</td>
<td>Created</td>
<td>Amount</td>
<td>VAT</td>
<td>Country</td>
<td>Method</td>
<td>Status</td>
<td></td>
</tr>
</thead>
<tbody>
{#each invoices as row (row.id)}
<tr>
<td>{row.id}</td>
<td>{formatDate(row.time, true, true, false)}</td>
<td><Euro amount={row.amount}/></td>
<td><Euro amount={row.vat}/></td>
<td>{row.country}</td>
<td>{row.payment_method}</td>
<td>
{#if row.status === "open"}
Waiting for payment
{:else if row.status === "processing"}
Payment received, waiting for confirmations
{:else if row.status === "paid"}
Paid
{:else if row.status === "expired"}
Expired
{:else if row.status === "canceled"}
Canceled
{:else}
{row.status}
{/if}
</td>
<td>
{#if row.status === "open"}
<a href="/api/user/pay_invoice/{row.id}" class="button button_highlight">
<i class="icon">paid</i> Pay
</a>
{/if}
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</section>
+38 -28
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import ProgressBar from "util/ProgressBar.svelte";
import { formatDataVolume } from "util/Formatting"
import { formatDataVolume, formatEuros } from "util/Formatting"
import { user } from "lib/UserStore";
let { total = 0, used = 0 }: {
@@ -9,6 +9,10 @@ let { total = 0, used = 0 }: {
} = $props();
let frac = $derived(used / total)
let bill_shock = $derived($user !== null && $user.monthly_transfer_cap === total)
let billable = $derived($user !== null && $user.subscription.price_per_tb_bandwidth > 0)
let billed = $derived(billable && $user.usage_based_billing)
let included = $derived($user === null ? 0 : $user.subscription.monthly_transfer_cap)
</script>
<ProgressBar total={total} used={used}></ProgressBar>
@@ -25,48 +29,54 @@ let frac = $derived(used / total)
</div>
</div>
{#if billed && included > 0 && used > included}
<p>
Data transfer above the {formatDataVolume(included, 3)} included in your
plan is billed separately, at
{formatEuros($user.subscription.price_per_tb_bandwidth, 2)} per TB.
</p>
{/if}
{#if frac > 1}
<div class="highlight_yellow">
<p>
You have used all of your data cap. People can still download your
files, but premium features are disabled. This means that the
download page shows Nova branding, people who download your
files have a daily download limit and hotlinking is disabled.
You have used all of your data transfer, so your files can't be
downloaded until your usage over the last 30 days drops below the
limit. Logged in users with data transfer left on their own plan
can still download them.
</p>
{#if $user !== null && $user.monthly_transfer_cap > 0}
{#if bill_shock}
<p>
You have a billshock limit configured. <a
href="/user/sharing">increase or disable the limit</a> to
continue sharing files.
This is your bill shock limit. <a href="/user/sharing">Increase
or disable the limit</a> to continue sharing files.
</p>
{:else}
<p>
Upgrade your plan{#if billable} or enable
<a href="/user/sharing">usage based billing</a>{/if} to continue
sharing files.
</p>
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options
</a>
{/if}
<a class="button button_highlight" href="/#pro">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{:else if frac > 0.8}
<div class="highlight_blue">
<p>
You have used {(frac*100).toFixed(0)}% of your data cap. If your
data runs out the premium features related to downloading will be
disabled. This means that the download page shows Nova
branding, people who download your files have a daily download limit
and hotlinking is disabled.
You have used {(frac*100).toFixed(0)}% of your data transfer. When
it runs out your files can't be downloaded anymore.
</p>
{#if $user !== null && $user.monthly_transfer_cap > 0}
{#if bill_shock}
<p>
You have a billshock limit configured. <a
href="/user/sharing">increase or disable the limit</a> to
continue sharing files.
This is your bill shock limit, you can change it in the
<a href="/user/sharing">sharing settings</a>.
</p>
{:else}
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options
</a>
{/if}
<a class="button button_highlight" href="/#pro">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{/if}
@@ -1,124 +0,0 @@
<script>
import { onMount } from "svelte";
let patreon_result = $state("")
let patreon_message = $state("")
let patreon_error = $state("")
onMount(() => {
if (window.location.hash.startsWith("#")) {
const hash = window.location.hash.replace("#", "");
const result = hash.split('&').reduce((res, item) => {
const parts = item.split('=')
res[parts[0]] = decodeURIComponent(parts[1])
return res;
}, {});
if (result.patreon_result) {
patreon_result = result.patreon_result
}
if (result.patreon_message) {
patreon_message = result.patreon_message
}
if (result.patreon_error) {
patreon_error = result.patreon_error
}
}
})
</script>
{#if patreon_result !== ""}
{#if patreon_error === "patreon_authentication_denied"}
<div class="highlight_yellow">
Please press "Allow" when asked if Nova can access your
profile.
</div>
{:else if patreon_result === "error"}
<div class="highlight_red">
<p>
An error occurred while linking Patreon subscription. Check if
there are any Nova integrations under "Logged in with
Patreon" on this page: <a
href="https://www.patreon.com/settings/apps">https://www.patreon.com/settings/apps</a>.
Try disconnecting all Nova logins and try again.
</p>
<li>
This can also happen if you canceled your Patreon membership
before upgrading your Nova account. In that case, go to
the <a
href="https://www.patreon.com/nova/membership">memberships
page</a> and activate your membership again. If you already paid
in the last 30 days you will not be charged again.
</li>
<p>
It might also help to try linking the subscription in a
different web browser. Sometimes cookies or cached redirects can
cause issues with the authentication process. Try linking your
subscription in <a
href="https://www.mozilla.org/firefox/">Firefox</a> for example.
</p>
<p>
If the information above does not solve your issue then please
contact me on <a
href="https://www.patreon.com/messages">Patreon</a> or <a
href="https://discord.gg/UDjaBGwr4p">Discord</a>. When
contacting support please provide the following
information:<br/> Server response: {patreon_message}<br/> Server
error code: {patreon_error}
</p>
</div>
{:else if patreon_result === "pledge_not_found"}
<div class="highlight_yellow">
<p>
We were not able to find your payment on Patreon. There can be a
few reasons for this, which I will list below:
</p>
<ol>
<li>
Your payment is not confirmed yet. It can take up to 30
minutes before your payment is confirmed. If you paid with
PayPal it's usually instant, but with creditcard it can take
longer. If your payment is not confirmed after 30 minutes
please contact me on <a
href="https://www.patreon.com/messages">Patreon</a> or <a
href="https://discord.gg/UDjaBGwr4p">Discord</a>.
</li>
<li>
You pledged without selecting a support tier. It happens
sometimes that people pledge an amount of money without
selecting a support tier. If you don't have a tier
Nova won't know which subscription you should get,
regardless of how much you paid. To fix this you can select
a tier from <a
href="https://www.patreon.com/nova/membership">the
memberships page</a> and proceed to checkout. If you already
pledged the right amount you will not have to pay again.
</li>
<li>
Or you have not pledged at all yet. In that case it's
simple: <a
href="https://www.patreon.com/nova/membership">go to
Patreon</a> and purchase a membership.
</li>
</ol>
<p>
When contacting support please provide the following
information:<br/>Server response: {patreon_message}<br/>Server
error code: {patreon_error}
</p>
</div>
{:else if patreon_result === "success"}
<div class="highlight_green">
Success! Your Patreon pledge has been linked to your Nova
account. You are now able to use Pro features.
</div>
{/if}
<br/>
{/if}
<style>
.highlight_red, .highlight_yellow {
text-align: initial;
}
</style>
+4 -10
View File
@@ -2,16 +2,15 @@
import AccountSettings from "./AccountSettings.svelte";
import APIKeys from "./APIKeys.svelte";
import Transactions from "./Transactions.svelte";
import Subscription from "./Subscription.svelte";
import ConnectApp from "./ConnectApp.svelte";
import ActivityLog from "./ActivityLog.svelte";
import DepositCredit from "./DepositCredit.svelte";
import TabMenu, { type Tab } from "util/TabMenu.svelte";
import Dashboard from "./dashboard/Dashboard.svelte";
import AffiliatePrompt from "./AffiliatePrompt.svelte";
import { onMount } from "svelte";
import { get_user, type User } from "lib/NovaAPI";
import SharingSettings from "./SharingSettings.svelte";
import SubscriptionManage from "./SubscriptionManage.svelte";
let pages: Tab[] = [
{
@@ -31,17 +30,12 @@ let pages: Tab[] = [
icon: "shopping_cart",
subpages: [
{
path: "/user/subscription",
path: "/user/subscription/manage",
title: "Manage",
icon: "shopping_cart",
component: Subscription,
component: SubscriptionManage,
}, {
path: "/user/prepaid/deposit",
title: "Deposit Credit",
icon: "account_balance_wallet",
component: DepositCredit,
}, {
path: "/user/prepaid/transactions",
path: "/user/subscription/transactions",
title: "Transactions",
icon: "receipt",
component: Transactions,
+31 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { onMount } from "svelte";
import { formatDataVolume } from "util/Formatting";
import { formatDataVolume, formatEuros } from "util/Formatting";
import ProgressBar from "util/ProgressBar.svelte";
import { loading_run } from "lib/Loading";
import { get_endpoint, put_user } from 'lib/NovaAPI';
@@ -28,6 +28,19 @@ const update_user = async (e: SubmitEvent) => {
})
}
const set_usage_based_billing = (e: Event) => {
const input = e.target as HTMLInputElement
loading_run(async () => {
try {
await put_user({usage_based_billing: input.checked})
success_message.set(true, "Usage based billing updated")
} catch (err) {
input.checked = !input.checked
success_message.set(false, "Failed to update user: "+err)
}
})
}
let transfer_used = $state(0)
let load_transfer_used = () => {
let today = new Date()
@@ -75,6 +88,23 @@ onMount(async () => {
<section>
<SuccessMessage bind:this={success_message}/>
{#if $user !== null && $user.subscription.type === "subscription"}
<h2>Usage based billing</h2>
<p>
When your storage or data transfer goes over the limits of your
plan, uploads and downloads are blocked. With usage based billing
they keep working and the usage above the limits is billed at
{formatEuros($user.subscription.price_per_tb_storage, 2)} per TB per
month for storage and
{formatEuros($user.subscription.price_per_tb_bandwidth, 2)} per TB
for data transfer.
</p>
<label>
<input type="checkbox" checked={$user.usage_based_billing} onchange={set_usage_based_billing}/>
Enable usage based billing
</label>
{/if}
<h2>Bill shock limit</h2>
<p>
Billshock limit in terabytes per month (1 TB = 1000 GB). Set to 0 to
+35 -51
View File
@@ -1,14 +1,16 @@
<script lang="ts">
import { formatDataVolume } from "util/Formatting"
import { formatDataVolume, formatEuros } from "util/Formatting"
import ProgressBar from "util/ProgressBar.svelte";
import { user } from "lib/UserStore";
let { total = 0, used = 0, disable_warnings = false }: {
let { total = 0, used = 0 }: {
total?: number;
used?: number;
disable_warnings?: boolean;
} = $props();
let frac = $derived(total <= 0 ? 0 : used / total)
let billable = $derived($user !== null && $user.subscription.price_per_tb_storage > 0)
let billed = $derived(billable && $user.usage_based_billing)
</script>
<ProgressBar total={total} used={used}></ProgressBar>
@@ -25,58 +27,40 @@ let frac = $derived(total <= 0 ? 0 : used / total)
</div>
</div>
{#if !disable_warnings}
{#if frac > 2.0}
<div class="highlight_red">
<span class="warn_text">
You are using more than 200% of your allowed storage space!
</span>
<p>
We have started deleting your files to free up space. If you do not
want to lose any more files please upgrade to a subscription which
supports the volume of storage which you need.
</p>
<a class="button button_highlight" href="/#pro">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{:else if frac > 1.0}
<div class="highlight_red">
<p>
You have used all of your storage space. You won't be able to
upload new files anymore. Please upgrade to a higher support
tier to continue uploading files.
</p>
<a class="button button_highlight" href="/#pro">
<i class="icon">bolt</i> Upgrade options
</a>
<p>
Your files will not be deleted any sooner than normal at this
moment. When your storage usage is over 200% we will start
deleting your files to free up the space.
</p>
</div>
{:else if frac > 0.8}
<div class="highlight_yellow">
<p>
You have used {(frac*100).toFixed(0)}% of your
storage space. If your storage space runs out you won't be able
to upload new files anymore. Please upgrade to a higher support
tier to continue uploading files.
</p>
<a class="button button_highlight" href="/#pro">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{#if billed}
{#if frac > 1}
<p>
Storage above the limit of your plan is billed separately, at
{formatEuros($user.subscription.price_per_tb_storage, 2)} per TB per
month.
</p>
{/if}
{:else if frac > 1}
<div class="highlight_yellow">
<p>
You are storing more than your plan allows, so you can't upload new
files. Your existing files stay available. Delete some files or
upgrade your plan to continue uploading{#if billable}, or enable
<a href="/user/sharing">usage based billing</a> to pay for the
storage above the limit{/if}.
</p>
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{:else if frac > 0.8}
<div class="highlight_blue">
<p>
You have used {(frac*100).toFixed(0)}% of your storage space. When
it runs out you won't be able to upload new files anymore.
</p>
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options
</a>
</div>
{/if}
<style>
.warn_text {
font-weight: bold;
font-size: 1.5em;
}
.gauge_labels {
display: flex;
justify-content: space-between;
-189
View File
@@ -1,189 +0,0 @@
<script lang="ts">
import Euro from "util/Euro.svelte"
import SuccessMessage from "util/SuccessMessage.svelte";
import PatreonActivationResult from "./PatreonActivationResult.svelte";
import { loading_finish, loading_start } from "lib/Loading";
import { user } from "lib/UserStore";
import { put_user } from "lib/NovaAPI";
let subscription: string = $state($user === null ? "" : $user.subscription.id)
let success_message: SuccessMessage = $state()
const update = async (plan: string) => {
const form = new FormData()
form.append("subscription", plan)
loading_start()
try {
await put_user({subscription: plan})
success_message.set(true, "Subscription updated")
} catch (err) {
success_message.set(false, "Failed to update subscription: "+err)
} finally {
loading_finish()
}
}
</script>
<section>
{#if window.location.hash === "#checkout_complete"}
<div class="highlight_green">
<h2>Payment successful!</h2>
<p>
Thank you for supporting Nova! The credit has been added
to your account balance.
</p>
<p>
If your account credit has not been updated, please check the
status of your invoice on <a
href="/user/prepaid/deposit#invoices">the invoices page</a>.
Depending on the payment processor you used it can take a while
before your credit is deposited. SEPA transfers can take up to
two working days for example. When the deposit is complete you
will receive an e-mail. If it takes too long, contact
support@nova.storage.
</p>
</div>
{:else if window.location.hash === "#order_expired"}
<div class="highlight_yellow">
<h2>Order expired</h2>
<p>
This order has expired. Please create a new order on the <a
href="/user/prepaid/deposit">credit deposit page</a>.
</p>
</div>
{:else if window.location.hash === "#order_canceled"}
<div class="highlight_yellow">
<h2>Order canceled</h2>
<p>
You have chosen to cancel the order. If you still want to
proceed with the order you can initiate payment again from the
<a href="/user/prepaid/deposit">deposit page</a>. If not then
you can let the invoice expire.
</p>
</div>
{/if}
<PatreonActivationResult/>
<h2>Manage subscription</h2>
<p>
Here you can switch between different subscription plans.
</p>
<p>
The Prepaid subscription is charged daily based on usage. When you reach
negative balance the subscription will automatically end. You need at
least <Euro amount={1e6}/> account credit to activate prepaid. Your
current credit amount is <Euro
amount={$user.balance_micro_eur}/>. You can deposit credit on the
<a href="/user/prepaid/deposit">credit deposit page</a>.
</p>
<h3>Available subscription plans</h3>
<SuccessMessage bind:this={success_message}/>
<div class="feat_table">
<div>
<div class="feat_label" class:feat_highlight={subscription === "prepaid"}>
Prepaid<br/>
{#if subscription === "prepaid"}
Currently active
{:else}
<button onclick={() => update("prepaid")}>
<i class="icon">attach_money</i>
Activate
</button>
{/if}
</div>
<div class="feat_normal round_tr" class:feat_highlight={subscription === "prepaid"}>
<p>
You will need a positive account balance to activate this
plan. The plan deactivates when your credit runs out.
</p>
<ul>
<li>
€1 / month minimum price (only charged when usage is
below €1)
</li>
<li>
€4 per TB per month for storage
</li>
<li>
€1 per TB for data transfer (with <a
href="/user/sharing">hotlinking</a>
enabled)
</li>
<li>
File <a href="/user/sharing">embedding control</a>
options
</li>
</ul>
</div>
</div>
<div>
<div class="feat_label" class:feat_highlight={subscription === ""}>
Free<br/>
{#if subscription === ""}
Currently active
{/if}
</div>
<div class="feat_normal round_br" class:feat_highlight={subscription === ""}>
<ul>
<li>Storage limit: 50 GB</li>
<li>Download limit: 50 GB per 30 days (sliding window)</li>
</ul>
</div>
</div>
</div>
</section>
<style>
.feat_table {
display: flex;
flex-direction: column;
}
.feat_table > div {
display: flex;
flex-direction: row;
}
.feat_table > div > div:first-child {
flex: 0 0 25%;
border-radius: 8px 0 0 8px;
}
.feat_table > div > div {
flex: 1 1 0;
margin: 2px;
padding: 0.5em;
word-wrap: break-word;
hyphens: auto;
border-radius: 0 8px 8px 0;
border: 2px solid var(--separator)
}
.feat_table > div > .feat_label {
border-top-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
border: 2px solid var(--separator);
font-size: 1.1em;
}
.feat_table > div > .feat_normal {
background: var(--card_color);
}
.feat_table > div > .feat_highlight {
border: 2px solid var(--highlight_color)
}
/* On small screens we stack the table vertically */
@media(max-width: 800px) {
.feat_table > div {
flex-direction: column;
}
.feat_table > div > div:first-child {
flex: 0 0 auto;
border-radius: 8px 8px 0 0;
}
.feat_table > div > div {
border-radius: 0 0 8px 8px;
}
}
</style>
@@ -0,0 +1,144 @@
<script lang="ts">
import Checkout from "layout/checkout/Checkout.svelte";
import { loading_run } from "lib/Loading";
import { get_user_invoices, type Invoice } from "lib/NovaAPI";
import { user } from "lib/UserStore";
import { onMount } from "svelte";
import Euro from "util/Euro.svelte";
import { formatDate } from "util/Formatting";
let invoices: Invoice[] = $state([])
let unpaid_invoice = $derived(
invoices.filter(row => row.status === "open").length
)
onMount(async () => {
await loading_run(async () => {
try {
invoices = await get_user_invoices()
} catch (err) {
console.error(err)
alert(err)
}
})
})
</script>
<section>
{#if window.location.hash === "#checkout_complete"}
<div class="highlight_green">
<h2>Payment successful!</h2>
<p>
Thank you for supporting Nova! The credit has been added
to your account balance.
</p>
<p>
If your account credit has not been updated, please check the
status of your invoice on <a
href="/user/subscription/manage#invoices">the invoices page</a>.
Depending on the payment processor you used it can take a while
before your credit is deposited. SEPA transfers can take up to
two working days for example. When the deposit is complete you
will receive an e-mail. If it takes too long, contact
support@nova.storage.
</p>
</div>
{:else if window.location.hash === "#order_expired"}
<div class="highlight_yellow">
<h2>Order expired</h2>
<p>
This order has expired. Please create a new order below.
</p>
</div>
{:else if window.location.hash === "#order_canceled"}
<div class="highlight_yellow">
<h2>Order canceled</h2>
<p>
You have chosen to cancel the order. If you still want to
proceed with the order you can initiate payment again below. If
not then you can let the invoice expire.
</p>
</div>
{/if}
<h2 id="deposit">Manage subscription</h2>
<p>
Subscriptions are charged from your account credit every day. Storage and
traffic above the amounts included in your plan are charged at €4 per TB
per month for storage and €1 per TB for data transfer. Your current
account balance is <Euro
amount={$user === null ? 0 : $user.balance_micro_eur}/>
</p>
{#if unpaid_invoice > 1}
<div class="highlight_yellow">
<p>
You still have an unpaid invoice open. Please pay that one
before requesting a new invoice. You can find unpaid
invoices at the bottom of this page. You can cancel an
invoice by clicking Pay, and then clicking the Back link at
the bottom of the page.
</p>
</div>
{:else}
<Checkout/>
{/if}
<h3 id="invoices">Past invoices</h3>
<p>
Invoices are deleted after one year of inactivity.
</p>
<div class="table_scroll">
<table style="text-align: left;">
<thead>
<tr>
<td>ID</td>
<td>Created</td>
<td>Amount</td>
<td>VAT</td>
<td>Country</td>
<td>Method</td>
<td>Status</td>
<td></td>
</tr>
</thead>
<tbody>
{#each invoices as row (row.id)}
<tr>
<td>{row.id}</td>
<td>{formatDate(row.time, true, true, false)}</td>
<td><Euro amount={row.amount}/></td>
<td><Euro amount={row.vat}/></td>
<td>{row.country}</td>
<td>{row.payment_method}</td>
<td>
{#if row.status === "open"}
Waiting for payment
{:else if row.status === "processing"}
Payment received, waiting for confirmations
{:else if row.status === "paid"}
Paid
{:else if row.status === "expired"}
Expired
{:else if row.status === "canceled"}
Canceled
{:else}
{row.status}
{/if}
</td>
<td>
{#if row.status === "open"}
<a href="/api/user/invoice/{row.id}/pay" class="button button_highlight">
<i class="icon">paid</i> Pay
</a>
{/if}
<a href="/api/user/invoice/{row.id}/pdf" target="_blank" class="button">
<i class="icon">description</i> PDF
</a>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</section>
@@ -9,9 +9,7 @@ import { formatDataVolume } from "util/Formatting";
<li>
Supporter level: {$user.subscription.name}<br/>
<i class="icon">shopping_cart</i>
<a href="/user/subscription">Manage subscriptions</a><br/>
<i class="icon">add_link</i>
<a href="/api/patreon_auth/start">Link Patreon subscription</a>
<a href="/user/subscription">Manage subscriptions</a>
</li>
{#if $user.balance_micro_eur !== 0}
@@ -19,10 +17,10 @@ import { formatDataVolume } from "util/Formatting";
Current account balance: <Euro amount={$user.balance_micro_eur}></Euro><br/>
<i class="icon">account_balance_wallet</i>
<a href="/user/prepaid/deposit">Deposit credit</a><br/>
<a href="/user/subscription/manage">Deposit credit</a><br/>
<i class="icon">receipt</i>
<a href="/user/prepaid/transactions">Transaction log</a>
<a href="/user/subscription/transactions">Transaction log</a>
{#if $user.balance_micro_eur > 0 && $user.subscription.id === ""}
<br/>
@@ -36,19 +34,31 @@ import { formatDataVolume } from "util/Formatting";
Max file size: {formatDataVolume($user.subscription.file_size_limit, 3)}
</li>
<li>
{#if $user.subscription.storage_limit > 0}
Storage limit: {formatDataVolume($user.subscription.storage_limit, 3)}
{:else}
{#if $user.subscription.storage_limit <= 0}
No storage limit
{:else if $user.subscription.price_per_tb_storage > 0}
Storage included: {formatDataVolume($user.subscription.storage_limit, 3)}
({formatDataVolume($user.storage_space_used, 3)} used)
{:else}
Storage limit: {formatDataVolume($user.subscription.storage_limit, 3)}
{/if}
</li>
<li>
{#if $user.subscription.monthly_transfer_cap > 0}
Data transfer limit: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
{:else}
{#if $user.subscription.monthly_transfer_cap <= 0}
No data transfer limit
{:else if $user.subscription.price_per_tb_bandwidth > 0}
Data transfer included: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
per month ({formatDataVolume($user.monthly_transfer_used, 3)} used)
{:else}
Data transfer limit: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
{/if}
</li>
{#if $user.subscription_period_end}
<li>
Subscription period: {$user.subscription_months} month{$user.subscription_months === 1 ? "" : "s"},
renews on {new Date($user.subscription_period_end).toLocaleDateString()}
</li>
{/if}
<li>
{#if $user.subscription.file_sharing === true}
File sharing enabled
@@ -34,13 +34,14 @@ let user: User = $state()
onMount(async () => {
user = await get_user()
if (user.monthly_transfer_cap > 0) {
transfer_cap = user.monthly_transfer_cap
} else if (user.subscription.monthly_transfer_cap > 0) {
transfer_cap = user.subscription.monthly_transfer_cap
} else {
transfer_cap = -1
// The lowest limit which blocks downloads. With usage based billing the
// plan's limit is billed instead, only the bill shock limit blocks
let caps = [user.monthly_transfer_cap]
if (!user.usage_based_billing || user.subscription.price_per_tb_bandwidth <= 0) {
caps.push(user.subscription.monthly_transfer_cap)
}
caps = caps.filter(cap => cap > 0)
transfer_cap = caps.length > 0 ? Math.min(...caps) : -1
storage_limit = user.subscription.storage_limit