Change charge description

This commit is contained in:
Fitti 2021-06-28 20:19:54 +02:00
parent 56b85ecdac
commit f88c622f94
2 changed files with 5 additions and 3 deletions

View File

@ -16,7 +16,6 @@ from lnbits.core.crud import get_wallet
async def get_charge_details(service_id):
details = {
"description": f"TwitchAlerts donation for service {str(service_id)}",
"time": 1440,
}
service = await get_service(service_id)

View File

@ -108,18 +108,21 @@ async def api_create_donation():
"""Takes data from donation form and creates+returns SatsPay charge"""
cur_code = "USD"
price = await btc_price(cur_code)
sats = g.data["sats"]
message = g.data.get("message", "")
amount = g.data["sats"] * (10 ** (-8)) * price
amount = sats * (10 ** (-8)) * price
webhook_base = request.scheme + "://" + request.headers["Host"]
service_id = g.data["service"]
service = await get_service(service_id)
charge_details = await get_charge_details(service.id)
name = g.data.get("name", "Anonymous")
description = f"{sats} sats donation from {name} to {service.twitchuser}"
charge = await create_charge(
amount=g.data["sats"],
amount=sats,
completelink=f"https://twitch.tv/{service.twitchuser}",
completelinktext="Back to Stream!",
webhook=webhook_base + "/twitchalerts/api/v1/postdonation",
description=description,
**charge_details)
await create_donation(
id=charge.id,