iap: wire coin packs to Cafe Bazaar SKUs + auto-select Bazaar billing in the APK
CI/CD / CI - API (dotnet build + engine sim) (push) Successful in 32s
CI/CD / CI - Web (tsc + next build) (push) Successful in 1m7s
CI/CD / Deploy - local stack (db + server + web) (push) Successful in 1m7s

- Pack ids now equal the Bazaar/Myket SKUs (Coin5K / Coin12K / Coin28K /
  Coin65K) in both the server source-of-truth (ProfileService.Packs) and the
  mock, so the IAB credit path (Id == ProductId) grants the right coins.
  Coin totals + prices already matched the registered products.
- storeBilling.getStore(): when running inside the Capacitor Android shell and
  no explicit NEXT_PUBLIC_STORE flavor is set, default to "bazaar" so the APK
  uses Cafe Bazaar IAB (the web build stays on the ZarinPal gateway). Myket's
  native bridge still overrides when present.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-12 14:37:13 +03:30
parent bf5b07962d
commit cd5742d623
3 changed files with 21 additions and 9 deletions
@@ -11,10 +11,12 @@ public class ProfileService
public static readonly CoinPackDto[] Packs = public static readonly CoinPackDto[] Packs =
{ {
new() { Id = "p1", Coins = 5000, Bonus = 0, PriceToman = 99000, Tag = "starter" }, // Id == Cafe Bazaar / Myket SKU (in-app product id). The store is the
new() { Id = "p2", Coins = 11000, Bonus = 1000, PriceToman = 199000, Tag = "popular" }, // source of truth for price; PriceToman here is only for display.
new() { Id = "p3", Coins = 24000, Bonus = 4000, PriceToman = 399000, Tag = "best" }, new() { Id = "Coin5K", Coins = 5000, Bonus = 0, PriceToman = 99000, Tag = "starter" },
new() { Id = "p4", Coins = 50000, Bonus = 15000, PriceToman = 799000 }, new() { Id = "Coin12K", Coins = 11000, Bonus = 1000, PriceToman = 199000, Tag = "popular" },
new() { Id = "Coin28K", Coins = 24000, Bonus = 4000, PriceToman = 399000, Tag = "best" },
new() { Id = "Coin65K", Coins = 50000, Bonus = 15000, PriceToman = 799000 },
}; };
private static ProfileDto Default(string userId, string? name) => new() private static ProfileDto Default(string userId, string? name) => new()
+5 -4
View File
@@ -988,10 +988,11 @@ export class MockOnlineService implements OnlineService {
async getCoinPacks(): Promise<CoinPack[]> { async getCoinPacks(): Promise<CoinPack[]> {
return [ return [
{ id: "p1", coins: 5000, bonus: 0, priceToman: 99000, tag: "starter" }, // id == Cafe Bazaar / Myket SKU (in-app product id).
{ id: "p2", coins: 11000, bonus: 1000, priceToman: 199000, tag: "popular" }, { id: "Coin5K", coins: 5000, bonus: 0, priceToman: 99000, tag: "starter" },
{ id: "p3", coins: 24000, bonus: 4000, priceToman: 399000, tag: "best" }, { id: "Coin12K", coins: 11000, bonus: 1000, priceToman: 199000, tag: "popular" },
{ id: "p4", coins: 50000, bonus: 15000, priceToman: 799000 }, { id: "Coin28K", coins: 24000, bonus: 4000, priceToman: 399000, tag: "best" },
{ id: "Coin65K", coins: 50000, bonus: 15000, priceToman: 799000 },
]; ];
} }
+10 -1
View File
@@ -28,11 +28,20 @@ interface MyketBridge {
declare global { declare global {
interface Window { interface Window {
MyketBilling?: MyketBridge; MyketBilling?: MyketBridge;
Capacitor?: { isNativePlatform?: () => boolean; getPlatform?: () => string };
} }
} }
export function getStore(): StoreId { export function getStore(): StoreId {
if (typeof window !== "undefined" && window.MyketBilling?.available) return "myket"; if (typeof window === "undefined") return ENV_STORE;
// Myket's native bridge wins when present (a Myket-flavored build).
if (window.MyketBilling?.available) return "myket";
// Honor an explicit build flavor.
if (ENV_STORE !== "web") return ENV_STORE;
// Otherwise, inside the Android app shell (Capacitor) default to Cafe Bazaar
// IAB — the APK ships to Bazaar, which requires its own billing. The web build
// stays on the web (ZarinPal) gateway.
if (window.Capacitor?.isNativePlatform?.()) return "bazaar";
return ENV_STORE; return ENV_STORE;
} }