mirror of https://git.sr.ht/~sircmpwn/fosspay
parent
b667230570
commit
85ce9c5327
@ -0,0 +1,20 @@ |
||||
#!/usr/bin/env python3 |
||||
from fosspay.database import db |
||||
from fosspay.objects import Invoice |
||||
from fosspay.config import _cfg |
||||
import sys |
||||
|
||||
if len(sys.argv) != 3: |
||||
print(f"Usage: {sys.argv[0]} <amount in cents> <comment>") |
||||
sys.exit(1) |
||||
|
||||
amount = int(sys.argv[1]) |
||||
comment = sys.argv[2] |
||||
|
||||
invoice = Invoice() |
||||
invoice.amount = amount |
||||
invoice.comment = comment |
||||
db.add(invoice) |
||||
db.commit() |
||||
|
||||
print(f"{_cfg('protocol')}://{_cfg('domain')}/invoice/{invoice.external_id}") |
@ -0,0 +1,60 @@ |
||||
{% extends "layout.html" %} |
||||
{% block scripts %} |
||||
<script> |
||||
window.stripe_key = "{{ _cfg("stripe-publish") }}"; |
||||
window.your_name = "{{ _cfg("your-name") }}"; |
||||
window.amount = {{invoice.amount}}; |
||||
window.invoice = "{{invoice.external_id}}"; |
||||
window.comment = "{{invoice.comment}}"; |
||||
const currency = "{{ _cfg("currency") }}"; |
||||
</script> |
||||
<script src="//checkout.stripe.com/checkout.js"></script> |
||||
<script src="../static/invoice.js"></script> |
||||
{% endblock %} |
||||
{% block body %} |
||||
<div class="well"> |
||||
<div class="container"> |
||||
<div class="row"> |
||||
<div class="col-md-8 col-md-offset-2"> |
||||
<h1>Invoice to {{ _cfg("your-name") }}</h1> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<noscript> |
||||
<div class="container"> |
||||
<div class="alert alert-danger"> |
||||
<p>This page requires Javascript. It's necessary to send your credit card number to |
||||
<a href="https://stripe.com/">Stripe</a> directly.</p> |
||||
</div> |
||||
</div> |
||||
</noscript> |
||||
<div class="container text-center hidden" id="thanks"> |
||||
<p>Thank you for your payment - it has been processed successfully.</p> |
||||
</div> |
||||
<div class="container text-center" id="donation-stuff"> |
||||
<h3>Invoice for ${{"{:.2f}".format(invoice.amount / 100)}}</h3> |
||||
<div class="row"> |
||||
<div class="col-md-4 col-md-offset-4"> |
||||
<p> |
||||
{{invoice.comment}} |
||||
</p> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-md-4 col-md-offset-4"> |
||||
<div class="alert alert-danger hidden" id="errors"><p></p></div> |
||||
<button class="btn btn-block btn-success" id="submit"> |
||||
Submit Payment |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="container text-center"> |
||||
<p> |
||||
<small class="text-muted"> |
||||
Powered by <a href="https://github.com/SirCmpwn/fosspay">fosspay</a>. |
||||
</small> |
||||
</p> |
||||
</div> |
||||
{% endblock %} |
Loading…
Reference in new issue