a26e0b93b5
- 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).
61 lines
1.7 KiB
Dart
61 lines
1.7 KiB
Dart
/// Product catalogue. Ids must match the entries created in the Play Console -
|
|
/// prices are **never** hardcoded in the app, the store returns them.
|
|
///
|
|
/// Only [removeAds] is wired into the UI so far (M7c); the rest of the table in
|
|
/// docs/monetization.md needs the economy that does not exist yet.
|
|
abstract final class ProductIds {
|
|
/// Non-consumable: hides interstitials. Rewarded video stays opt-in.
|
|
static const String removeAds = 'remove_ads';
|
|
|
|
/// Documents the seasonal pass that will follow in MVP-3.
|
|
static const String seasonPass = 'season_pass';
|
|
|
|
/// Consumable hard currency - needs server-side bookkeeping, not wired yet.
|
|
static const String coresSmall = 'cores_small';
|
|
|
|
static const Set<String> all = {removeAds, seasonPass, coresSmall};
|
|
|
|
/// Products the UI offers today.
|
|
static const Set<String> offered = {removeAds};
|
|
}
|
|
|
|
/// One purchasable item as the store describes it.
|
|
class StoreProduct {
|
|
const StoreProduct({
|
|
required this.id,
|
|
required this.title,
|
|
required this.price,
|
|
this.raw,
|
|
});
|
|
|
|
final String id;
|
|
final String title;
|
|
final String price;
|
|
final Object? raw;
|
|
|
|
@override
|
|
String toString() => '$id ($price)';
|
|
}
|
|
|
|
/// State of a purchase event, mapped from the platform.
|
|
enum PurchaseState { pending, purchased, restored, canceled, error }
|
|
|
|
class PurchaseEvent {
|
|
const PurchaseEvent({
|
|
required this.productId,
|
|
required this.state,
|
|
this.error,
|
|
this.complete = false,
|
|
this.raw,
|
|
});
|
|
|
|
final String productId;
|
|
final PurchaseState state;
|
|
final String? error;
|
|
|
|
/// True when the platform waits for `completePurchase` (Play: acknowledge
|
|
/// within three days, otherwise the purchase is refunded automatically).
|
|
final bool complete;
|
|
final Object? raw;
|
|
}
|