mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-14 23:09:24 +02:00
feat: store mor info about the webhook
call status
This commit is contained in:
parent
681883a8f9
commit
c5fdd35078
@ -49,15 +49,22 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||
if pay_link.webhook_headers:
|
||||
kwargs["headers"] = json.loads(pay_link.webhook_headers)
|
||||
|
||||
r = await client.post(pay_link.webhook_url, **kwargs)
|
||||
await mark_webhook_sent(payment, r.status_code)
|
||||
r: httpx.Response = await client.post(pay_link.webhook_url, **kwargs)
|
||||
await mark_webhook_sent(
|
||||
payment, r.status_code, r.is_success, r.reason_phrase, r.text
|
||||
)
|
||||
except Exception as 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:
|
||||
payment.extra["wh_status"] = status
|
||||
async def mark_webhook_sent(
|
||||
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(
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user