2022-10-18 14:30:50 +02:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
import Euro from "../util/Euro.svelte";
|
|
|
|
import { formatDate } from "../util/Formatting.svelte";
|
|
|
|
import LoadingIndicator from "../util/LoadingIndicator.svelte";
|
2023-09-14 01:35:27 +02:00
|
|
|
import MollieDeposit from "./MollieDeposit.svelte";
|
2022-10-18 14:30:50 +02:00
|
|
|
|
|
|
|
let loading = false
|
|
|
|
let credit_amount = 10
|
2023-09-15 18:10:35 +02:00
|
|
|
let tab = "mollie"
|
2022-10-18 14:30:50 +02:00
|
|
|
|
2023-09-14 01:35:27 +02:00
|
|
|
const checkout = async (network = "", amount = 0, country = "") => {
|
2022-10-18 14:30:50 +02:00
|
|
|
loading = true
|
2023-09-14 01:35:27 +02:00
|
|
|
|
|
|
|
if (amount < 10) {
|
|
|
|
alert("Amount needs to be at least €10")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:30:50 +02:00
|
|
|
const form = new FormData()
|
2023-09-14 01:35:27 +02:00
|
|
|
form.set("amount", amount*1e6)
|
2022-10-18 14:30:50 +02:00
|
|
|
form.set("network", network)
|
2023-09-14 01:35:27 +02:00
|
|
|
form.set("country", country)
|
2022-10-18 14:30:50 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
const resp = await fetch(
|
2023-09-14 01:35:27 +02:00
|
|
|
window.api_endpoint+"/user/invoice",
|
|
|
|
{method: "POST", body: form},
|
2022-10-18 14:30:50 +02:00
|
|
|
)
|
|
|
|
if(resp.status >= 400) {
|
|
|
|
let json = await resp.json()
|
|
|
|
throw json.message
|
|
|
|
}
|
|
|
|
|
|
|
|
window.location = (await resp.json()).checkout_url
|
|
|
|
} catch (err) {
|
|
|
|
alert(err)
|
|
|
|
} finally {
|
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let invoices = []
|
2023-09-15 18:10:35 +02:00
|
|
|
let unpaid_invoice = false
|
2022-10-18 14:30:50 +02:00
|
|
|
const load_invoices = async () => {
|
|
|
|
loading = true
|
|
|
|
try {
|
2023-09-14 01:35:27 +02:00
|
|
|
const resp = await fetch(window.api_endpoint+"/user/invoice")
|
2022-10-18 14:30:50 +02:00
|
|
|
if(resp.status >= 400) {
|
|
|
|
throw new Error((await resp.json()).message)
|
|
|
|
}
|
|
|
|
|
|
|
|
let invoices_tmp = await resp.json()
|
2023-09-15 18:10:35 +02:00
|
|
|
unpaid_invoice = false
|
2022-10-18 14:30:50 +02:00
|
|
|
invoices_tmp.forEach(row => {
|
|
|
|
row.time = new Date(row.time)
|
2023-09-15 18:10:35 +02:00
|
|
|
|
|
|
|
if (row.payment_method === "mollie" && row.status === "open") {
|
|
|
|
unpaid_invoice = true
|
|
|
|
}
|
2022-10-18 14:30:50 +02:00
|
|
|
})
|
|
|
|
invoices_tmp.sort((a, b) => {
|
|
|
|
return b.time - a.time
|
|
|
|
})
|
|
|
|
invoices = invoices_tmp
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
alert(err)
|
|
|
|
} finally {
|
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
load_invoices()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<LoadingIndicator loading={loading}/>
|
|
|
|
|
|
|
|
<section>
|
2023-11-29 12:43:33 +01:00
|
|
|
<h2 id="deposit">Deposit credit</h2>
|
2022-10-18 14:30:50 +02:00
|
|
|
<p>
|
2025-03-27 13:45:40 +01:00
|
|
|
Pixeldrain 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={window.user.balance_micro_eur}/>
|
2022-10-18 18:09:17 +02:00
|
|
|
</p>
|
2023-09-14 01:35:27 +02:00
|
|
|
|
2023-09-15 18:10:35 +02:00
|
|
|
<div class="tab_bar">
|
|
|
|
<button on:click={() => tab = "mollie"} class:button_highlight={tab === "mollie"}>
|
|
|
|
<i class="icon">euro</i>
|
|
|
|
Mollie
|
2022-10-18 14:30:50 +02:00
|
|
|
</button>
|
2023-09-15 18:10:35 +02:00
|
|
|
<button on:click={() => tab = "btcpay"} class:button_highlight={tab === "btcpay"}>
|
|
|
|
<i class="icon">currency_bitcoin</i>
|
|
|
|
Crypto
|
2022-10-18 14:30:50 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
2023-09-15 18:10:35 +02:00
|
|
|
{#if tab === "mollie"}
|
|
|
|
{#if unpaid_invoice}
|
|
|
|
<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}
|
|
|
|
<MollieDeposit/>
|
|
|
|
{/if}
|
|
|
|
{:else if tab === "btcpay"}
|
|
|
|
<div class="highlight_border">
|
|
|
|
<p style="text-align: initial">
|
|
|
|
Alternatively you can use Bitcoin, Lightning network (<a
|
|
|
|
href="https://btcpay.pixeldrain.com/embed/uS2mbWjXUuaAqMh8XLjkjwi8oehFuxeBZxekMxv68LN/BTC/ln"
|
|
|
|
target="_blank" rel="noreferrer">node info</a>) and Dogecoin to deposit
|
|
|
|
credits on your pixeldrain account. You must pay the full amount as
|
|
|
|
stated on the invoice, else your payment will fail.
|
|
|
|
</p>
|
|
|
|
<p style="text-align: initial">
|
|
|
|
Do note that it is not possible to withdraw coins from your
|
|
|
|
pixeldrain account. It's not a wallet. Any amount of money you
|
|
|
|
deposit has to be used up.
|
|
|
|
</p>
|
|
|
|
Deposit amount €
|
|
|
|
<input type="number" bind:value={credit_amount} min="10"/>
|
|
|
|
<br/>
|
|
|
|
Choose payment method:<br/>
|
|
|
|
<button on:click={() => {checkout("btc", credit_amount)}}>
|
|
|
|
<i class="icon">currency_bitcoin</i> Bitcoin
|
|
|
|
</button>
|
|
|
|
<button on:click={() => {checkout("btc_lightning", credit_amount)}}>
|
|
|
|
<i class="icon">bolt</i> Lightning network
|
|
|
|
</button>
|
|
|
|
<button on:click={() => {checkout("doge", credit_amount)}}>
|
|
|
|
<span class="icon_unicode">Ð</span> Dogecoin
|
|
|
|
</button>
|
2024-05-17 11:58:52 +02:00
|
|
|
<button on:click={() => {checkout("xmr", credit_amount)}}>
|
|
|
|
<span class="icon_unicode">M</span> Monero
|
|
|
|
</button>
|
2023-09-15 18:10:35 +02:00
|
|
|
</div>
|
|
|
|
{/if}
|
2022-10-18 14:30:50 +02:00
|
|
|
|
2023-09-14 14:29:05 +02:00
|
|
|
<h3 id="invoices">Past invoices</h3>
|
2022-10-18 15:42:40 +02:00
|
|
|
<p>
|
|
|
|
Invoices are deleted after one year of inactivity.
|
|
|
|
</p>
|
2022-10-18 14:30:50 +02:00
|
|
|
<div class="table_scroll">
|
|
|
|
<table style="text-align: left;">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-01-24 13:58:52 +01:00
|
|
|
<td>ID</td>
|
2022-10-18 14:30:50 +02:00
|
|
|
<td>Created</td>
|
|
|
|
<td>Amount</td>
|
2023-09-14 01:35:27 +02:00
|
|
|
<td>VAT</td>
|
|
|
|
<td>Country</td>
|
|
|
|
<td>Method</td>
|
2022-10-18 14:30:50 +02:00
|
|
|
<td>Status</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{#each invoices as row (row.id)}
|
2022-10-18 15:42:40 +02:00
|
|
|
<tr>
|
2024-01-24 13:58:52 +01:00
|
|
|
<td>{row.id}</td>
|
2022-10-18 15:42:40 +02:00
|
|
|
<td>{formatDate(row.time, true, true, false)}</td>
|
2023-09-14 01:35:27 +02:00
|
|
|
<td><Euro amount={row.amount}/></td>
|
|
|
|
<td><Euro amount={row.vat}/></td>
|
|
|
|
<td>{row.country}</td>
|
|
|
|
<td>{row.payment_method}</td>
|
2022-10-18 15:42:40 +02:00
|
|
|
<td>
|
2023-09-14 01:35:27 +02:00
|
|
|
{#if row.status === "InvoiceCreated" || row.status === "open"}
|
|
|
|
Waiting for payment
|
2022-10-18 15:42:40 +02:00
|
|
|
{:else if row.status === "InvoiceProcessing"}
|
|
|
|
Payment received, waiting for confirmations
|
2023-09-14 01:35:27 +02:00
|
|
|
{:else if row.status === "InvoiceSettled" || row.status === "paid"}
|
2022-10-18 15:42:40 +02:00
|
|
|
Paid
|
|
|
|
{:else if row.status === "InvoiceExpired"}
|
|
|
|
Expired
|
2023-09-14 01:35:27 +02:00
|
|
|
{:else if row.status === "canceled"}
|
|
|
|
Canceled
|
2022-10-18 15:42:40 +02:00
|
|
|
{:else}
|
|
|
|
{row.status}
|
|
|
|
{/if}
|
|
|
|
</td>
|
|
|
|
<td>
|
2023-09-14 01:35:27 +02:00
|
|
|
{#if row.status === "New" || row.status === "InvoiceCreated" || row.status === "open"}
|
|
|
|
<a href="/api/user/pay_invoice/{row.id}" class="button button_highlight">
|
2022-10-18 15:42:40 +02:00
|
|
|
<i class="icon">paid</i> Pay
|
|
|
|
</a>
|
|
|
|
{/if}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2022-10-18 14:30:50 +02:00
|
|
|
{/each}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</section>
|