fix: persist webhook call status

This commit is contained in:
Vlad Stan
2022-11-25 14:12:13 +02:00
parent ead710e591
commit 1a9cd81ee9
6 changed files with 39 additions and 13 deletions
+4 -4
View File
@@ -35,18 +35,18 @@ async def call_webhook(charge: Charges):
json=public_charge(charge),
timeout=40,
)
except AssertionError:
charge.webhook = None
return {"webhook_success": r.is_success, "webhook_message": r.reason_phrase}
except Exception as e:
logger.warning(f"Failed to call webhook for charge {charge.id}")
logger.warning(e)
return {"webhook_success": False, "webhook_message": str(e)}
async def fetch_onchain_balance(charge: Charges):
endpoint = (
f"{charge.config['mempool_endpoint']}/testnet"
if charge.config["network"] == "Testnet"
else charge.config["mempool_endpoint"]
if charge.config.network == "Testnet"
else charge.config.mempool_endpoint
)
async with httpx.AsyncClient() as client:
r = await client.get(endpoint + "/api/address/" + charge.onchainaddress)