diff --git a/main.py b/main.py index cff3873..77d2d38 100644 --- a/main.py +++ b/main.py @@ -86,7 +86,20 @@ def account(): link = accounts.getAccountLink(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 = '' + + + return render_template('account.html', account=account, address=address, link=link, name=name, webhook=webhook, payments=paymentHTML) @app.route('/account/edit', methods=['POST']) def payout(): diff --git a/payments.py b/payments.py index 487a923..99013fa 100644 --- a/payments.py +++ b/payments.py @@ -77,6 +77,14 @@ def check_payments(): continue for address in addresses: 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' finalise_payment(address,tx) @@ -98,11 +106,22 @@ def generateAddress(): 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): - print(payment) # Send webhook + print("Finalising payment") + print(payment) + print(tx) email = payment['email'] payout = accounts.getAccountAddress(email) diff --git a/templates/account.html b/templates/account.html index 89e077a..f258907 100644 --- a/templates/account.html +++ b/templates/account.html @@ -49,7 +49,9 @@
-
{{payments|safe}}
+
+

Payment History

{{payments|safe}} +