purchaseContext property
PurchaseContext
get
purchaseContext
The catalogue facts a store purchase needs to tell an upgrade from a downgrade: the tiers in the catalogue's own order (cheapest first), the tier of every product key the rows list, and the tier of every store product id they name.
Grandfathered products are IN both maps, deliberately: the customer may hold one, and the rail can only rank the subscription it is replacing if something names its tier. A store id is the only handle on a held product no current offering carries, which is why both stores' ids map too.
Built from plans on every read rather than cached, so it can never describe a catalogue other than the one on screen.
Implementation
PurchaseContext get purchaseContext {
return PurchaseContext(
tierOrder: <String>[for (final MagicStarterPlan plan in _plans) plan.id],
tierOfProduct: <String, String>{
for (final MagicStarterProduct product in _catalogueProducts)
product.key: product.tier,
},
tierOfStoreProduct: <String, String>{
for (final MagicStarterProduct product in _catalogueProducts)
for (final String? id in <String?>[
product.storeIds.appStore,
product.storeIds.play,
])
?id: product.tier,
},
);
}