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
@@ -147,6 +147,9 @@ pick = "Elige un formato:"
cancelled = "Cancelado."
[btn]
pay_lightning = "⚡ Pagar con Lightning"
pay_stars = "⭐ Pagar con Estrellas"
with_stars = "{{.Label}} · ⭐ {{.Stars}}"
qr = "Código QR"
copy_link = "Copiar enlace"
share = "Compartir"
@@ -422,6 +425,10 @@ header = """
Página {{.Page}} de {{.Pages}}. Toca una para verla y recibirla otra vez."""
[owner]
revenue_title = "<b>Ingresos</b>"
stars_refunded = "Devueltas {{.Amount}} al usuario {{.User}} por la compra <code>{{.ID}}</code>. Lo que otorgó se retiró."
stars_refund_failed = "Telegram rechazó la devolución: {{.Reason}}"
stars_not_refundable = "Esta compra con Estrellas no se puede devolver (estado: {{.Status}})."
books_ok = "el libro mayor y los saldos coinciden"
ln_ok = "disponible"
ln_down = "NO disponible"
@@ -462,7 +469,11 @@ Crear un código de regalo:
gift_code = "Código de regalo: <code>{{.Code}}</code>\nUsos: {{.Uses}}"
granted = "Listo. El pase de {{.ID}} dura hasta el {{.Until}}."
credit_usage = "Ejemplo: <code>/credit 123456789 500</code>"
refund_usage = "Ejemplos:\n<code>/refund 123456789 500</code>\n<code>/refund 123456789 pass 24h</code>"
refund_usage = """
Ejemplos:
<code>/refund 123456789 500</code>
<code>/refund 123456789 pass 24h</code>
<code>/refund PURCHASE_ID</code> devuelve un pago con Estrellas"""
no_pass = "Esa billetera no tiene un pase activo para extender."
credited = "Listo. Se agregaron {{.Amount}} a {{.ID}}. Saldo: {{.Balance}}."
blocklist_empty = "La lista de bloqueo está vacía."
@@ -731,6 +742,8 @@ cancel_confirm = "Cancelar \"{{.Title}}\"?"
cancelled = "Cancelado."
[app.buy]
method_stars = "Estrellas ⭐"
method_lightning = "Lightning ⚡"
unavailable = "Los pagos no están configurados en este bot."
step = "Paso {{.Step}} de {{.Total}}"
target_title = "Para quién es?"
@@ -755,6 +768,9 @@ at_once = "Al mismo tiempo"
none = "Sin límite"
[app.invoice]
refunded = "Devuelto"
stars_pay = "Abrir el pago otra vez"
stars_waiting = "Esperando a que Telegram confirme el pago…"
qr_alt = "Factura Lightning como código QR"
copy = "Copiar la factura"
waiting = "Esperando el pago · {{.Time}}"
@@ -890,3 +906,29 @@ Comparte tu enlace. Cuando alguien que invitaste pague una primera compra en sat
Invitados: {{.Invited}} · Compraron algo: {{.Converted}}
Ganado: {{.Earned}} · En espera: {{.Pending}}"""
[unit.stars]
one = "{{.N}} Estrella"
other = "{{.N}} Estrellas"
[stars]
refunded = "Se te devolvió el pago de {{.Title}}: {{.Amount}} volvieron a tu saldo de Telegram."
payment_problem = "Tu pago llegó, pero no pude asociarlo a un pedido. El dueño del bot lo ve y lo va a resolver."
precheck_closed = "Esta factura está cerrada. Empieza la compra otra vez, por favor."
precheck_failed = "Esta factura no coincide con tu pedido. Empieza la compra otra vez, por favor."
invoice_description = "{{.Title}} para The Noderunners Download Bot, tuyo en cuanto llega el pago."
credits_title = "{{.Amount}} en créditos"
offer = """
<b>Pagar con Estrellas de Telegram</b>
Un pase cubre esta descarga. Empieza en cuanto llega el pago."""
intro = """
<b>Pagar con Estrellas de Telegram</b>
Los mismos pases y créditos, pagados con tu saldo de Estrellas en Telegram."""
[owner.revenue_lightning]
one = "Lightning: {{.Amount}} de {{.Count}} compra"
other = "Lightning: {{.Amount}} de {{.Count}} compras"
[owner.revenue_stars]
one = "Estrellas: {{.Amount}} de {{.Count}} compra, {{.Refunded}} devueltas"
other = "Estrellas: {{.Amount}} de {{.Count}} compras, {{.Refunded}} devueltas"