SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 728ca563a6cf653d38ce6abd2e96cff2288293a8
parent 7ecc903350e6e95e2387f681bf9991b63590b771
Author: nickfarrow <nick@nickfarrow.com>
Date:   Tue,  8 Mar 2022 00:29:37 +1100

display generic errors on payment page

Diffstat:
Msatsale.py | 12+++++++++---
Mstatic/satsale.js | 2++
Mtemplates/index.html | 2+-
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/satsale.py b/satsale.py @@ -123,6 +123,7 @@ class create_payment(Resource): @api.response(200, "Success", invoice_model) @api.response(400, "Invalid payment method") @api.response(406, "Amount below dust limit") + @api.response(522, "Error fetching address from node") def get(self): "Create Payment" """Initiate a new payment with an `amount` in `config.base_currecy`.""" @@ -164,9 +165,14 @@ class create_payment(Resource): } # Get an address / invoice, and create a QR code - invoice["address"], invoice["rhash"] = node.get_address( - invoice["btc_value"], invoice["uuid"] - ) + try: + invoice["address"], invoice["rhash"] = node.get_address( + invoice["btc_value"], invoice["uuid"] + ) + except Exception as e: + logging.error("Failed to fetch address") + return {"message": "Error fetching address. Check config.."}, 522 + node.create_qr(invoice["uuid"], invoice["address"], invoice["btc_value"]) # Save invoice to database diff --git a/static/satsale.js b/static/satsale.js @@ -25,7 +25,9 @@ function payment(payment_data) { return payment_uuid }, function(data) { + console.error(data["responseJSON"]["message"]); $('#error').show(); + $('#error_message').text(data["responseJSON"]["message"]).html(); return ""; }).then(function(payment_uuid) { if (payment_uuid != "") { diff --git a/templates/index.html b/templates/index.html @@ -42,7 +42,7 @@ </div> <div id="error" style="display:none;"> - <p style="padding:0;">Error generating invoice! Amount too small?</p> + <p style="padding:0;"><span id="error_message">Error generating invoice!</span></p> </div> </br>