mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-12 22:12:41 +02:00
feat: store mor info about the webhook
call status
This commit is contained in:
@ -49,15 +49,22 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||||||
if pay_link.webhook_headers:
|
if pay_link.webhook_headers:
|
||||||
kwargs["headers"] = json.loads(pay_link.webhook_headers)
|
kwargs["headers"] = json.loads(pay_link.webhook_headers)
|
||||||
|
|
||||||
r = await client.post(pay_link.webhook_url, **kwargs)
|
r: httpx.Response = await client.post(pay_link.webhook_url, **kwargs)
|
||||||
await mark_webhook_sent(payment, r.status_code)
|
await mark_webhook_sent(
|
||||||
|
payment, r.status_code, r.is_success, r.reason_phrase, r.text
|
||||||
|
)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error(ex)
|
logger.error(ex)
|
||||||
await mark_webhook_sent(payment, -1)
|
await mark_webhook_sent(payment, -1, False, "Unexpected Error", str(ex))
|
||||||
|
|
||||||
|
|
||||||
async def mark_webhook_sent(payment: Payment, status: int) -> None:
|
async def mark_webhook_sent(
|
||||||
payment.extra["wh_status"] = status
|
payment: Payment, status: int, is_success: bool, reason_phrase="", text=""
|
||||||
|
) -> None:
|
||||||
|
payment.extra["wh_status"] = status # keep for backwards compability
|
||||||
|
payment.extra["wh_success"] = is_success
|
||||||
|
payment.extra["wh_message"] = reason_phrase
|
||||||
|
payment.extra["wh_response"] = text
|
||||||
|
|
||||||
await core_db.execute(
|
await core_db.execute(
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user