mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
Merge remote-tracking branch 'origin/master' into satspay
This commit is contained in:
commit
cbdf97f949
@ -27,6 +27,12 @@ from .crud import (
|
||||
update_payment_status,
|
||||
get_wallet_payment,
|
||||
)
|
||||
|
||||
|
||||
class PaymentFailure(Exception):
|
||||
pass
|
||||
|
||||
|
||||
async def create_invoice(
|
||||
*,
|
||||
wallet_id: str,
|
||||
@ -160,8 +166,9 @@ async def pay_invoice(
|
||||
)
|
||||
await delete_payment(temp_id, conn=conn)
|
||||
else:
|
||||
raise Exception(
|
||||
payment.error_message or "Failed to pay_invoice on backend."
|
||||
raise PaymentFailure(
|
||||
payment.error_message
|
||||
or "Payment failed, but backend didn't give us an error message."
|
||||
)
|
||||
|
||||
return invoice.payment_hash
|
||||
|
@ -12,7 +12,7 @@ from lnbits import bolt11
|
||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||
|
||||
from .. import core_app, db
|
||||
from ..services import create_invoice, pay_invoice, perform_lnurlauth
|
||||
from ..services import PaymentFailure, create_invoice, pay_invoice, perform_lnurlauth
|
||||
from ..tasks import sse_listeners
|
||||
|
||||
|
||||
@ -127,6 +127,8 @@ async def api_payments_pay_invoice():
|
||||
return jsonify({"message": str(e)}), HTTPStatus.BAD_REQUEST
|
||||
except PermissionError as e:
|
||||
return jsonify({"message": str(e)}), HTTPStatus.FORBIDDEN
|
||||
except PaymentFailure as e:
|
||||
return jsonify({"message": str(e)}), 520
|
||||
except Exception as exc:
|
||||
raise exc
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
{% block head_scripts %}{% endblock %}
|
||||
</head>
|
||||
|
||||
|
@ -102,12 +102,8 @@ class LndRestWallet(Wallet):
|
||||
timeout=180,
|
||||
)
|
||||
|
||||
if r.is_error:
|
||||
error_message = r.text
|
||||
try:
|
||||
error_message = r.json()["error"]
|
||||
except:
|
||||
pass
|
||||
if r.is_error or r.json().get("payment_error"):
|
||||
error_message = r.json().get("payment_error") or r.text
|
||||
return PaymentResponse(False, None, 0, None, error_message)
|
||||
|
||||
data = r.json()
|
||||
|
Loading…
Reference in New Issue
Block a user