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-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 = []
|
|
|
|
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()
|
|
|
|
invoices_tmp.forEach(row => {
|
|
|
|
row.time = new Date(row.time)
|
|
|
|
})
|
|
|
|
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>
|
|
|
|
<h2>Deposit credits</h2>
|
|
|
|
<p>
|
2023-09-14 01:35:27 +02:00
|
|
|
Pixeldrain credits can be used for our prepaid plans, which are
|
|
|
|
different from the Patreon plans. With prepaid you only pay for what you
|
|
|
|
use, at a rate of €4 per TB per month for storage and €2 per TB for data
|
|
|
|
transfer.
|
2022-10-18 18:09:17 +02:00
|
|
|
</p>
|
|
|
|
<p>
|
2023-09-14 01:35:27 +02:00
|
|
|
Use the form below to deposit credit on your pixeldrain account using
|
|
|
|
Mollie. The minimum deposit is €10. <b>Mollie payments are currently
|
|
|
|
only available in Europe</b>.
|
2022-10-18 18:09:17 +02:00
|
|
|
</p>
|
2023-09-14 01:35:27 +02:00
|
|
|
|
|
|
|
<MollieDeposit on:checkout={e => checkout("mollie", e.detail.amount, e.detail.country)}/>
|
|
|
|
|
2022-10-18 18:09:17 +02:00
|
|
|
<h3>Crypto payments</h3>
|
|
|
|
<p>
|
|
|
|
Alternatively you can use Bitcoin, Lightning network (<a
|
2022-10-18 14:30:50 +02:00
|
|
|
href="https://btcpay.pixeldrain.com/embed/uS2mbWjXUuaAqMh8XLjkjwi8oehFuxeBZxekMxv68LN/BTC/ln"
|
2022-12-24 11:37:31 +01:00
|
|
|
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.
|
2022-10-18 14:30:50 +02:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
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>
|
2022-10-18 18:09:17 +02:00
|
|
|
<div class="highlight_border">
|
2022-10-18 14:30:50 +02:00
|
|
|
Deposit amount €
|
2023-09-14 01:35:27 +02:00
|
|
|
<input type="number" bind:value={credit_amount} min="10"/>
|
2022-10-18 14:30:50 +02:00
|
|
|
<br/>
|
2022-10-18 18:09:17 +02:00
|
|
|
Choose payment method:<br/>
|
2023-09-14 01:35:27 +02:00
|
|
|
<button on:click={() => {checkout("btc", credit_amount)}}>
|
2022-10-18 14:30:50 +02:00
|
|
|
<span class="icon_unicode">₿</span> Bitcoin
|
|
|
|
</button>
|
2023-09-14 01:35:27 +02:00
|
|
|
<button on:click={() => {checkout("btc_lightning", credit_amount)}}>
|
2022-10-18 14:30:50 +02:00
|
|
|
<i class="icon">bolt</i> Lightning network
|
|
|
|
</button>
|
2023-09-14 01:35:27 +02:00
|
|
|
<button on:click={() => {checkout("doge", credit_amount)}}>
|
2022-10-18 14:30:50 +02:00
|
|
|
<span class="icon_unicode">Ð</span> Dogecoin
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2022-10-18 18:09:17 +02:00
|
|
|
<h3>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>
|
|
|
|
<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>
|
|
|
|
<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>
|