iap: wire coin packs to Cafe Bazaar SKUs + auto-select Bazaar billing in the APK
- 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:
+10
-1
@@ -28,11 +28,20 @@ interface MyketBridge {
|
||||
declare global {
|
||||
interface Window {
|
||||
MyketBilling?: MyketBridge;
|
||||
Capacitor?: { isNativePlatform?: () => boolean; getPlatform?: () => string };
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user