diff --git a/src/components/screens/BuyCoinsScreen.tsx b/src/components/screens/BuyCoinsScreen.tsx index c84d58d..209f14a 100644 --- a/src/components/screens/BuyCoinsScreen.tsx +++ b/src/components/screens/BuyCoinsScreen.tsx @@ -6,7 +6,7 @@ import { ScreenHeader, ScreenShell } from "@/components/online/ScreenHeader"; import { useSessionStore } from "@/lib/session-store"; import { useI18n } from "@/lib/i18n"; import { getService } from "@/lib/online/service"; -import { consumeStorePurchase, isStoreBilling, purchaseViaStore } from "@/lib/storeBilling"; +import { consumeStorePurchase, isPurchaseDisabled, isStoreBilling, purchaseViaStore } from "@/lib/storeBilling"; import { sound } from "@/lib/sound"; import { CoinPack } from "@/lib/online/types"; import { cn } from "@/lib/cn"; @@ -39,6 +39,14 @@ export function BuyCoinsScreen() { setBusy(p.id); setMsg(""); + // Google Play build: coin purchases are intentionally not wired (no Iranian + // IAB on Play). Show a notice instead of starting any payment flow. + if (isPurchaseDisabled()) { + setMsg(t("buy.notImplemented")); + setBusy(null); + return; + } + // Inside a store build (Cafe Bazaar / Myket), route through store billing. if (isStoreBilling()) { try { diff --git a/src/lib/i18n.tsx b/src/lib/i18n.tsx index 0a7b0c4..827d411 100644 --- a/src/lib/i18n.tsx +++ b/src/lib/i18n.tsx @@ -139,6 +139,7 @@ const fa: Dict = { "buy.bonus": "هدیه", "buy.redirecting": "صفحهٔ پرداخت در تب جدید باز شد. پس از پرداخت، سکه‌ها به‌صورت خودکار اضافه می‌شوند.", "buy.failed": "پرداخت در دسترس نیست. بعداً دوباره تلاش کنید.", + "buy.notImplemented": "پیاده‌سازی نشده است.", "buy.popular": "محبوب", "buy.best": "بهترین", "buy.starter": "شروع", @@ -528,6 +529,7 @@ const en: Dict = { "buy.bonus": "bonus", "buy.redirecting": "Payment opened in a new tab. Your coins will be added automatically once you pay.", "buy.failed": "Payment unavailable. Please try again later.", + "buy.notImplemented": "Not implemented.", "buy.popular": "Popular", "buy.best": "Best value", "buy.starter": "Starter", diff --git a/src/lib/storeBilling.ts b/src/lib/storeBilling.ts index f88e2b4..af667ae 100644 --- a/src/lib/storeBilling.ts +++ b/src/lib/storeBilling.ts @@ -14,7 +14,7 @@ import { registerPlugin } from "@capacitor/core"; import { CoinPack } from "./online/types"; -export type StoreId = "bazaar" | "myket" | "web"; +export type StoreId = "bazaar" | "myket" | "web" | "googleplay"; const ENV_STORE = ((process.env.NEXT_PUBLIC_STORE as StoreId | undefined) ?? "web"); const PACKAGE = process.env.NEXT_PUBLIC_APP_PACKAGE ?? "com.bargevasat.app"; @@ -54,7 +54,18 @@ export function getStore(): StoreId { /** True when coin purchases should go through a store (not the web ZarinPal gateway). */ export function isStoreBilling(): boolean { - return getStore() !== "web"; + const s = getStore(); + return s !== "web" && s !== "googleplay"; +} + +/** + * True for the Google Play build, where real-money coin purchases are NOT wired + * (no Iranian IAB on Play, and we don't ship a Play billing path). The Buy-Coins + * screen shows a "not implemented" notice instead of starting a purchase. Set via + * the build flavor `NEXT_PUBLIC_STORE=googleplay`. + */ +export function isPurchaseDisabled(): boolean { + return getStore() === "googleplay"; } function skuFor(pack: CoinPack): string {