2525from lnbits .utils .exchange_rates import (
2626 fiat_amount_as_satoshis ,
2727 get_fiat_rate_satoshis ,
28+ satoshis_amount_as_fiat ,
2829)
2930from lnbits .utils .nostr import normalize_public_key
3031
@@ -266,13 +267,18 @@ async def api_ticket_create(
266267 price = await fiat_amount_as_satoshis (price , event .currency )
267268
268269 invoice_unit = event .currency
270+ fiat_amount = price
269271 fiat_provider = None
270272 if payment_method == "fiat" :
271- if not _is_fiat_currency (event .currency ):
272- raise HTTPException (
273- status_code = HTTPStatus .BAD_REQUEST ,
274- detail = "Fiat checkout requires a fiat-denominated ticket price." ,
275- )
273+ if _is_fiat_currency (event .currency ):
274+ invoice_unit = event .currency
275+ else :
276+ invoice_unit = event .fiat_currency
277+ fiat_amount = await satoshis_amount_as_fiat (price , invoice_unit )
278+ extra ["fiat" ] = True
279+ extra ["currency" ] = invoice_unit
280+ extra ["fiatAmount" ] = fiat_amount
281+ extra ["rate" ] = await get_fiat_rate_satoshis (invoice_unit )
276282 wallet = await get_wallet (event .wallet )
277283 if not wallet :
278284 raise HTTPException (
@@ -293,7 +299,7 @@ async def api_ticket_create(
293299 wallet_id = event .wallet ,
294300 invoice_data = CreateInvoice (
295301 out = False ,
296- amount = price ,
302+ amount = fiat_amount if payment_method == "fiat" else price ,
297303 unit = invoice_unit ,
298304 fiat_provider = fiat_provider ,
299305 memo = f"{ event_id } " ,
0 commit comments