Phase 4: Telegram Stars payments

- Stars as a second payment method for passes and credit packs, next to
  Lightning (STARS_ENABLED, prices in [stars_prices] / STARS_PRICES, set
  on their own). Invoices in XTR with no provider token and one price;
  pre-checkout checks payer, state, currency and amount;
  successful_payment settles through the same transaction as Lightning,
  so entitlement is identical. Idempotent by telegram_payment_charge_id
  (unique index).
- Migration 00009: payment_method on purchases and ledger entries, plus
  stars_amount, tg_charge_id and refunded_at on purchases. Stars
  purchases never reach LNbits.
- Chat: buy screen, /credits, /account and the over-limit offer show
  Lightning first and a Pay with Stars button.
- Mini App: Lightning and Stars switch on Buy; Stars use
  createInvoiceLink and WebApp.openInvoice, confirmed by the server-side
  payment event.
- Owner /refund <purchase or charge ID> calls refundStarPayment and takes
  back the credits or pass; refunded_payment messages do the same once.
  /stats shows revenue by payment method.
- The sats referral reward counts Lightning purchases only.
- The bot now asks Telegram for pre_checkout_query updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 21:20:03 +00:00
co-authored by Claude Opus 5.5
parent f7ceadc462
commit 2b5625e9d4
37 changed files with 1915 additions and 114 deletions
+43 -1
View File
@@ -146,6 +146,9 @@ pick = "Kies een formaat:"
cancelled = "Geannuleerd."
[btn]
pay_lightning = "⚡ Betalen met Lightning"
pay_stars = "⭐ Betalen met Stars"
with_stars = "{{.Label}} · ⭐ {{.Stars}}"
qr = "QR-code"
copy_link = "Link kopiëren"
share = "Delen"
@@ -421,6 +424,10 @@ header = """
Pagina {{.Page}} van {{.Pages}}. Tik op een download om hem te bekijken en opnieuw te krijgen."""
[owner]
revenue_title = "<b>Omzet</b>"
stars_refunded = "{{.Amount}} terugbetaald aan gebruiker {{.User}} voor aankoop <code>{{.ID}}</code>. Wat die opleverde is teruggenomen."
stars_refund_failed = "Telegram weigerde de terugbetaling: {{.Reason}}"
stars_not_refundable = "Deze Stars-aankoop kan niet worden terugbetaald (status: {{.Status}})."
books_ok = "grootboek en saldi kloppen"
ln_ok = "bereikbaar"
ln_down = "NIET bereikbaar"
@@ -461,7 +468,11 @@ Een cadeaucode maken:
gift_code = "Cadeaucode: <code>{{.Code}}</code>\nKeer te gebruiken: {{.Uses}}"
granted = "Klaar. De pas van {{.ID}} loopt tot {{.Until}}."
credit_usage = "Voorbeeld: <code>/credit 123456789 500</code>"
refund_usage = "Voorbeelden:\n<code>/refund 123456789 500</code>\n<code>/refund 123456789 pass 24h</code>"
refund_usage = """
Voorbeelden:
<code>/refund 123456789 500</code>
<code>/refund 123456789 pass 24h</code>
<code>/refund PURCHASE_ID</code> betaalt een Stars-betaling terug"""
no_pass = "Die wallet heeft geen actieve pas om te verlengen."
credited = "Klaar. {{.Amount}} toegevoegd aan {{.ID}}. Saldo: {{.Balance}}."
blocklist_empty = "De blokkeerlijst is leeg."
@@ -730,6 +741,8 @@ cancel_confirm = "\"{{.Title}}\" annuleren?"
cancelled = "Geannuleerd."
[app.buy]
method_stars = "Telegram Stars ⭐"
method_lightning = "Lightning ⚡"
unavailable = "Betalingen zijn op deze bot niet ingesteld."
step = "Stap {{.Step}} van {{.Total}}"
target_title = "Voor wie is het?"
@@ -754,6 +767,9 @@ at_once = "Tegelijk"
none = "Geen limiet"
[app.invoice]
refunded = "Terugbetaald"
stars_pay = "De betaling opnieuw openen"
stars_waiting = "Wachten tot Telegram de betaling bevestigt…"
qr_alt = "Lightning-factuur als QR-code"
copy = "Factuur kopiëren"
waiting = "Wachten op betaling · {{.Time}}"
@@ -889,3 +905,29 @@ Deel je link. Als iemand die je uitnodigde een eerste aankoop in sats (Lightning
Uitgenodigd: {{.Invited}} · Iets gekocht: {{.Converted}}
Verdiend: {{.Earned}} · Wacht nog: {{.Pending}}"""
[unit.stars]
one = "{{.N}} Star"
other = "{{.N}} Stars"
[stars]
refunded = "Je betaling voor {{.Title}} is terugbetaald: {{.Amount}} staat weer op je Telegram-saldo."
payment_problem = "Je betaling is binnen, maar ik kon hem niet aan een bestelling koppelen. De eigenaar van de bot ziet het en lost het op."
precheck_closed = "Deze factuur is gesloten. Begin de aankoop opnieuw."
precheck_failed = "Deze factuur past niet bij je bestelling. Begin de aankoop opnieuw."
invoice_description = "{{.Title}} voor The Noderunners Download Bot, van jou zodra de betaling binnen is."
credits_title = "{{.Amount}} aan tegoed"
offer = """
<b>Betalen met Telegram Stars</b>
Een pas dekt deze download. Hij begint zodra de betaling binnen is."""
intro = """
<b>Betalen met Telegram Stars</b>
Dezelfde passen en hetzelfde tegoed, betaald met je Stars-saldo in Telegram."""
[owner.revenue_lightning]
one = "Lightning: {{.Amount}} uit {{.Count}} aankoop"
other = "Lightning: {{.Amount}} uit {{.Count}} aankopen"
[owner.revenue_stars]
one = "Stars: {{.Amount}} uit {{.Count}} aankoop, {{.Refunded}} terugbetaald"
other = "Stars: {{.Amount}} uit {{.Count}} aankopen, {{.Refunded}} terugbetaald"