fix: stop trying to process payment more than once
All checks were successful
Build Docker / Build Image (push) Successful in 25s
All checks were successful
Build Docker / Build Image (push) Successful in 25s
This commit is contained in:
parent
607e11f8ec
commit
ca5e54449c
15
main.py
15
main.py
@ -86,7 +86,20 @@ def account():
|
|||||||
link = accounts.getAccountLink(account)
|
link = accounts.getAccountLink(account)
|
||||||
webhook = accounts.getAccountWebhook(account)
|
webhook = accounts.getAccountWebhook(account)
|
||||||
|
|
||||||
return render_template('account.html', account=account, address=address, link=link, name=name, webhook=webhook)
|
|
||||||
|
userPayments = payments.getUserPayments(account)
|
||||||
|
userPayments = [payment for payment in userPayments if payment['status'] == 'Confirmed']
|
||||||
|
paymentHTML = '<ul class="list-group" style="max-width: 700px;margin: auto;">'
|
||||||
|
for payment in userPayments:
|
||||||
|
paymentHTML += f'<li class="list-group-item"><span>{payment["amount"]} HNS'
|
||||||
|
if payment['data']:
|
||||||
|
paymentHTML += f' - {payment["data"]}'
|
||||||
|
paymentHTML += '</span></li>'
|
||||||
|
|
||||||
|
paymentHTML += '</ul>'
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('account.html', account=account, address=address, link=link, name=name, webhook=webhook, payments=paymentHTML)
|
||||||
|
|
||||||
@app.route('/account/edit', methods=['POST'])
|
@app.route('/account/edit', methods=['POST'])
|
||||||
def payout():
|
def payout():
|
||||||
|
21
payments.py
21
payments.py
@ -77,6 +77,14 @@ def check_payments():
|
|||||||
continue
|
continue
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
if tx['address'] == address['address']:
|
if tx['address'] == address['address']:
|
||||||
|
if 'hashes' in address:
|
||||||
|
if tx['txid'] in address['hashes']:
|
||||||
|
print("Already confirmed")
|
||||||
|
continue
|
||||||
|
|
||||||
|
address['hashes'].append(tx['txid'])
|
||||||
|
|
||||||
|
address['hashes'] = [tx['txid']]
|
||||||
address['status'] = 'Confirmed'
|
address['status'] = 'Confirmed'
|
||||||
finalise_payment(address,tx)
|
finalise_payment(address,tx)
|
||||||
|
|
||||||
@ -98,11 +106,22 @@ def generateAddress():
|
|||||||
return resp.json()["address"]
|
return resp.json()["address"]
|
||||||
|
|
||||||
|
|
||||||
|
def getUserPayments(email):
|
||||||
|
# Get all payments for a user
|
||||||
|
with open('data/addresses.json', 'r') as f:
|
||||||
|
addresses = json.load(f)
|
||||||
|
userPayments = []
|
||||||
|
for address in addresses:
|
||||||
|
if address['email'] == email:
|
||||||
|
userPayments.append(address)
|
||||||
|
return userPayments
|
||||||
|
|
||||||
|
|
||||||
def finalise_payment(payment,tx):
|
def finalise_payment(payment,tx):
|
||||||
print(payment)
|
|
||||||
# Send webhook
|
# Send webhook
|
||||||
|
print("Finalising payment")
|
||||||
|
print(payment)
|
||||||
|
print(tx)
|
||||||
email = payment['email']
|
email = payment['email']
|
||||||
payout = accounts.getAccountAddress(email)
|
payout = accounts.getAccountAddress(email)
|
||||||
|
|
||||||
|
@ -49,7 +49,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<div>{{payments|safe}}</div>
|
<div>
|
||||||
|
<h1 class="text-center">Payment History</h1>{{payments|safe}}
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<footer class="bg-dark">
|
<footer class="bg-dark">
|
||||||
<div class="container py-4 py-lg-5">
|
<div class="container py-4 py-lg-5">
|
||||||
|
Loading…
Reference in New Issue
Block a user