m7c: Play Billing and a complete deletion path

- billing module with a testable seam: models (product ids, purchase events),
  StoreClient + PlayStoreClient over in_app_purchase, Entitlements persisted in
  SharedPreferences, BillingService orchestrating query/buy/restore/grant.
- rules encoded: grant before completePurchase (Play refunds unacknowledged
  purchases after three days), pending purchases are shown but never granted,
  restorePurchases on start so a reinstall keeps the purchase, and Remove Ads
  only hides interstitials - rewarded video stays available.
- ads gate: AdsService.adsRemoved stops both the counter and the preload, so an
  owner never requests an interstitial.
- settings sheet: shop section (price from the store, never hardcoded),
  "restore purchases", and "delete local data" with confirmation; the existing
  mail-based deletion request stays the account-deletion path since the app has
  no accounts.
- 9 new tests with a fake store cover purchase, restore, pending, cancel,
  error, restart persistence, missing store and a store that throws. 17 total.
- verified on device: the app talks to the real Play Billing service
  (IInAppBillingService in logcat) and degrades to "no products created"
  without a crash; com.android.vending.BILLING is in the merged manifest.
- docs: monetization 7c (rules + verification), decision D6 (local entitlement
  until purchases affect the server), compliance rows for billing/restore/
  deletion, blocked.md 3c (create remove_ads in the Console).
- release 0.9.0 (13).
This commit is contained in:
2026-10-25 04:06:44 +01:00
parent 82bd496cc9
commit a26e0b93b5
15 changed files with 868 additions and 6 deletions
+37
View File
@@ -145,6 +145,43 @@ Das war der Release-Blocker: ohne Nachricht hätte die App in der EU ohne Einwil
Damit sind die drei Play-Anforderungen erfüllt: Einwilligung **vor** der ersten Ad-Anfrage,
keine Ads ohne Zustimmung, und ein **dauerhafter** Weg, die Einwilligung zu ändern.
## 7c. Play Billing (M7c, umgesetzt 2026-10-25)
**Katalog** aus §3, aber bewusst klein gestartet: nur **Remove Ads** (`remove_ads`,
Non-Consumable) ist im UI. Season Pass, Starter Pack und Cores brauchen eine Ökonomie,
die es noch nicht gibt – die IDs stehen bereits in `ProductIds`, damit die Erweiterung
eine Datenzeile ist und kein Umbau.
| Baustein | Datei |
|---|---|
| Katalog + Ereignismodelle | `lib/src/billing/models.dart` |
| Store-Schnittstelle + Play-Implementierung | `lib/src/billing/store_client.dart` |
| Besitzstand (persistiert) | `lib/src/billing/entitlements.dart` |
| Ablaufsteuerung | `lib/src/billing/billing_service.dart` |
| UI | Einstellungen-Sheet: „Werbung entfernen“, „Käufe wiederherstellen“ |
**Regeln, die eingehalten werden**
1. Preise kommen ausschließlich aus dem Store (`queryProductDetails`), nichts ist hartkodiert.
2. `restorePurchases` läuft **beim Start** – Neuinstallation stellt den Besitz wieder her.
3. `purchased`/`restored` → erst Entitlement schreiben, dann `completePurchase`
(Play erstattet nach 3 Tagen nicht bestätigte Käufe automatisch).
4. `pending` wird gemeldet, aber **nie** freigeschaltet (z. B. Barzahlung im Laden).
5. Besitz wird sofort persistiert (`iron_arc.entitlements`), damit ein Absturz zwischen
Store-Ereignis und Bestätigung nichts verliert.
6. Remove Ads schaltet nur **Interstitials** ab (`AdsService.adsRemoved`); Rewarded bleibt
freiwillig – sonst wäre die Belohnung für Käufer weg.
7. Ohne Play-Dienst (Seitelladen, kein Konto) gibt es keinen Crash, sondern einen klaren
Zustand: „Play Store nicht erreichbar“ bzw. „Keine Produkte im Play Store angelegt“.
**Verifikation:** 9 Unit-Tests mit einem Fake-Store (`app/test/billing_test.dart`) decken
Kauf, Restore, Pending, Abbruch, Fehler, Neustart-Persistenz und den Fall „kein Store“ ab.
Auf dem Gerät wurde zusätzlich geprüft, dass die App den echten Billing-Dienst anspricht
(`IInAppBillingService` im Logcat) und ohne angelegte Produkte sauber degradiert.
**Noch offen:** serverseitige Belegprüfung (siehe [D6](decisions.md)) und die Produkte
im Play Console (siehe [status/blocked.md](status/blocked.md)).
## 8. Offene Punkte
1. Ads schon in MVP-1 (Test-IDs) oder erst M7? (siehe README, offene Entscheidungen)